How to merge ReactJS project svelte? Or How to insert .svelte file into ReactJs project?

怎甘沉沦 提交于 2019-12-11 15:26:57

问题


How to merge node_module, project dependencies, of both Svelte and ReactJs?

I've seen guides showing how to include ReactJS file into a Svelte app

<SvelteComponent this={First} {...this.props}/>

That produces the following error:

Constructor is not a Constructor error


回答1:


Svelte and React are not compatible to import and use the other framework component directly.

It is definitely possible to create a Svelte app inside of a React app or vice-versa though.

You would have to instantiate the app like normal inside of the other app. The Svelte docs show how you can bind a Svelte app to a DOM node, which you can include in a React component. Make sure you also add the DOM node inside of that component, such as <div id="svelte-app" />.



来源:https://stackoverflow.com/questions/57283544/how-to-merge-reactjs-project-svelte-or-how-to-insert-svelte-file-into-reactjs

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