How can one use a polymer component inside a react component ? Is it possible?

我的未来我决定 提交于 2021-02-07 14:24:09

问题


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 : enter image description here

This is poly-react.html the polymer element: enter image description here

This is my polyreact.jsx which also has polymer element inside

enter image description here

and the polymer inside above jsx started working with this transformation which can be done using the tutorial:

enter image description here

The index file also has to be changed like this:

enter image description here

hope this helps!!!!!!!!



来源:https://stackoverflow.com/questions/30594809/how-can-one-use-a-polymer-component-inside-a-react-component-is-it-possible

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!