Is there a “Best Practices” on designing an application written both in React and React-Native?

Generally, you can share a lot of business logic between react native and web applications. By business logic, I basically mean the logic in your app that aren’t components. Trying to share components is pretty hard, since the base level components are different (View vs div, etc), and you generally want things structured pretty differently on the web vs a mobile app.

If you are using redux or something like it to manage your app’s state, you could share the reducers, action creators, api calls, etc. You would put all of that into a shared package, and then both the web and native apps would import them and use them as needed. I wouldn’t go this route until it is clear you need an app. It would be easy enough to extract at a later date when it is necessary.

If you’re using graphql, you benefit from the fact that a lot of the shared logic is encoded in the schema. Your mobile app can query the same graphql server and get the same data or include more/less fields depending on what is necessary for the mobile app to function.

Leave a Comment