What is the best practice to share common code between Create-React-App (web) and Expo-App?


#1

Disclaimer: I am a newbie in react-native. For my use case, i have a simple crud app using CRA and redux. Currently I have a single repo containing src for both of my backend and frontend.

I like to add an expo app. I also like to refactor out redux code into a share project as follow.

/MyProject
./backend
./web
./mobile
./share

What is the best practices to wire these project up? As you can see, i am trying to do a mono-repo. Do you use any tool? such as bitsrc.io ? Any recommend tutorial in this topic? Thanks


#2

I don’t know if it’s a best practice, but I wrote an article on how to use the Render Props pattern to share code between mobile and web apps. You can find it here: https://medium.com/react-native-training/sharing-code-between-react-web-and-react-native-applications-7f451af26378


#3

Thanks reggie3. I am specifically looking into the a minimalistic technique for monorepo and currently trying out yarn workspace. But thanks for the article.