问题
I have used google's polymer to make web components but i am also very interested in giving react a try. So i want to know whether it is possible to use the polymer component from inside the render function of a react component ?
回答1:
Yes it is possible ! I did it using a method thats kinda bit complicated but i would love to share it.
if you have already used polymer then just directly use the polymer the way you use it any other polymer element. all you have to do is convert this react folder to a js. You can follow this tutorial in order to convert a jsx to js. and use any polymer element without a problem.
https://www.youtube.com/watch?v=4WUATF3hGUQ
This is not my tutorial but something i saw on youtube . all credits for this tutorial go to codingwithjesse
As asked by WiredPraire , i would like to show you with an example
this is my index.html :
This is poly-react.html the polymer element:
This is my polyreact.jsx which also has polymer element inside
and the polymer inside above jsx started working with this transformation which can be done using the tutorial:
The index file also has to be changed like this:
hope this helps!!!!!!!!
来源:https://stackoverflow.com/questions/30594809/how-can-one-use-a-polymer-component-inside-a-react-component-is-it-possible