React Native + React (for web) seed project

前端 未结 6 1026
长发绾君心
长发绾君心 2020-12-28 17:34

Is it possible to setup a project which has code for both React Native(Mobile app) + React(web), having the code shred between platforms except for the UI part.

Have

6条回答
  •  一生所求
    2020-12-28 18:16

    Yes, absolutely possible. We've done it before using this lib react-native-web. https://github.com/necolas/react-native-web

    beside index.ios.js and index.android.js, you will need create index.web.js, the content should be similar like this.

    import { AppRegistry } from 'react-native';
    import App from './app/Containers/App/App.container';
    
    AppRegistry.registerComponent('ReactNativeWeb', () => App);
    AppRegistry.runApplication('ReactNativeWeb', { rootTag: document.getElementById('react-app') });

    also you need to create your own nodejs code to serve up the bundle. full reference

提交回复
热议问题