inokawa / react-native-react-bridge

An easy way to integrate your React (or Preact/React Native Web) app into React Native app with WebView.
https://www.npmjs.com/package/react-native-react-bridge
MIT License
256 stars 18 forks source link

React-native-web support #150

Closed billouboq closed 3 months ago

billouboq commented 9 months ago

Hello,

First of all thank you for this package, it's really clever and helpful.

I was wondering if it would be hard to add react-native-web support in it ?

For a quick context on why it would be awesome, we are using react-native and react-native-web and allowing react-native-web inside would allow us for example to reuse all of our already made components inside the webview

inokawa commented 9 months ago

That sounds interesting.

If rnrb.preact is true, this library converts react imports to preact imports here: https://github.com/inokawa/react-native-react-bridge/blob/4d9a19b2ca119c42ab97a1ebbaba9ae468f33eb0/src/plugin/transformer.js#L16C20-L34

I'm not sure what level of support is the best, but adding rnrb.reactNativeWeb like option and converting react-native imports under web entry to react-native-web may work as you expected.

billouboq commented 9 months ago

Will try it at my work and if it works will make a pull request for it, thanks for the headups ! 👍

wilhemknight commented 4 months ago

That sounds interesting.

If rnrb.preact is true, this library converts react imports to preact imports here: https://github.com/inokawa/react-native-react-bridge/blob/4d9a19b2ca119c42ab97a1ebbaba9ae468f33eb0/src/plugin/transformer.js#L16C20-L34

I'm not sure what level of support is the best, but adding rnrb.reactNativeWeb like option and converting react-native imports under web entry to react-native-web may work as you expected.

Any Update on this i am trying to get react-native-web to work via the above suggestion but no luck so far

wilhemknight commented 4 months ago

Just got it to work by using import "react-native-web" directly from the webapp.js file