react-native-react-bridge icon indicating copy to clipboard operation
react-native-react-bridge copied to clipboard

React-native-web support

Open billouboq opened this issue 1 year ago • 4 comments

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

billouboq avatar Dec 07 '23 08:12 billouboq

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.

inokawa avatar Dec 07 '23 09:12 inokawa

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

billouboq avatar Dec 07 '23 10:12 billouboq

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 avatar May 04 '24 16:05 wilhemknight

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

wilhemknight avatar May 04 '24 17:05 wilhemknight