Example of code module sharing for React Native and Web
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
modules/src
native-project
web-project
LICENSE.md
README.md

README.md

An example of running shared code modules in a related React Native and React web app, using the lessons learned described in this post.

Update with possibly better alternative

After I wrote this, I found wix/wml which appears to be a cleaner way to do what I've implemented here. If I was implementing this now I'd definintely give the wml tool a shot.

Native App startup

cd native-project
yarn start

Web App Startup

cd web-project
yarn start

Code editor configuration

Since local copies of the /modules/src folders are copied into each project, you must be careful to not try to edit the copies, as they are not in source control and will be overwritten.

Whatever code editor/IDE you use, you should add a rule to ignore all of the copied files, as they will help clean up your editor as well as prevent searches from returning results from the copies.

For example, with vscode add the workspace setting:

"settings": {
    "files.exclude":{
        // defaults
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/CVS": true,
        "**/.DS_Store": true,
        // custom
        "src/modules/**": true
    }
}