This is a simple, basic monorepo for frontend development using React-Native & React-Native-Web. It is a template or starter kit to share code between different platforms (Web, Android, & iOS).
The repo creates a generic app called "tenta" (Latin for try or test) from shared code. The key to code sharing is React-Native's Platform-specific extensions. The extensions are .native.js
, .ios.js
or .android.js
and when used, the relevant platform file is compiled.
The main benefit of any monorepo is to share application logic. Another benefit is the rendering of individual components unique to each platform. Development is mobile-first AND then webapp.
- Get the repo
- From the root directory, do
yarn
- Change root/android/local.properties as needed
Required: React-Native working per Getting Started
For each platform, from the root directory, do
node_modules/.bin/webpack -p --progress
node_modules/.bin/webpack-dev-server --content-base public/ --config ./webpack.config.js --port 3001 --inline --hot --colors
- Manually open a browser to localhost:3001 to see webapp
- Inspect browser window = open console to see shared code working on button click
react-native run-android
react-native run-ios
or openios/tenta.xcodeproj
with Xcode
- Due to platform specific UI rendering, CSS & App code are not shared.
- 1 element (a button), native to each platform, is used ; it is attached to 1 function.
- 1 component (title) & 1 function (just logs console message) is shared for all 3 platforms.
- Lerna or Yarn Workspaces is not used ; there is only 1
node_modules
folder - State / Props / Redux are not used. You can add them or any other package, as needed
- Examples of Shared Code = a)
app/component/App
, b)app/component/Title
, c)common/example.js
, + d)common/nativeStyles.js
. If you want to create a NEW monorepo from scratch, start with React Native and use this repo as a model for all files & folders