Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-navigation for react-native-web?

Need to reuse the react-navigation code from mobile to react-native-web. But I could not able to get it work in web.

enter image description here

Should we need to use react-router for web separately?

How can we configure navigation commonly for both platform? I would love to see an example of this! It would be super helpful. Thank you!!

like image 1000
Balasubramanian Avatar asked Feb 06 '18 17:02

Balasubramanian


People also ask

Does react navigation work in React Native web?

"React Native for Web" makes it possible to run React Native components and APIs on the web using React DOM. This approach allows you to reuse most of React Navigation on the web because React Native for Web maps React Native primitives like View , Text , and others to their equivalents on the web.

Which navigation is best for React Native?

react-native-navigation: uses the underlying native APIs on iOS and Android, similar to createNativeStackNavigator. This is a popular alternative to React Navigation and may be a better fit for you if you are trying to integrate React Native into an existing large native app.


2 Answers

Maybe you can check this implementation

Using React Native, React Native Web and React Navigation in a single project

like image 128
jcvalerio Avatar answered Oct 11 '22 09:10

jcvalerio


The above answers are quite old now I'd say as react-navigation has upgraded itself quite a bit since then.

react-navigation v4 has intensive support for react native web, now you don't need to maintain two separate navigation objects for web and app.

This blog explains it in detail. https://codersera.com/blog/how-to-do-navigation-in-react-native-web-in-2020/

like image 40
Prashant Singh Avatar answered Oct 11 '22 09:10

Prashant Singh