Can we share code between react webapp and react native app and is react-native production ready

后端 未结 10 1406
终归单人心
终归单人心 2021-02-01 07:11

We have a stable version of a widget developed with reactjs. We would like to develop mobile version of the same. Is it better to develop with react native and share the code ac

10条回答
  •  孤独总比滥情好
    2021-02-01 07:41

    Rather than bloat this answer too much, I wrote a fairly in-depth guide about this at https://dev.to/kylessg/a-sensible-approach-to-cross-platform-development-with-react-and-react-native-57pk.

    To summarise though, you can get great amounts of codesharing between React and React Native but don't overreach on what you're sharing. Doing so may leave your code harder to maintain where you're trying to oversimplify valid differences between mobile and web.

    For myself, this is along the lines of:

    Shared:

    • Business logic
    • Communication with API
    • Polyfill possible shared functionality into an API (e.g. communication with analytics, local storage, network detection etc)
    • Stores, reducers app actions
    • HOCs

    Web/Mobile specific:

    • Presentational components
    • Navigation / routing
    • Styles

提交回复
热议问题