How to merge ReactJS project svelte? Or How to ins

2019-08-30 08:51发布


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


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" />.