The monorepo for native and web demo.
- Install packages:
On the root folder:
yarn- Start web demo:
cd apps/web
yarn dev- Start native demo:
cd apps/native
yarn start-
apps/nativethe React Native demo. -
apps/webthe React web demo. -
packages/demo-corethe model layer that could be shared between native and web.
-
The files in the
packages/demo-corefolder (the model layer) can import any other files in the same folder. -
The files in the
packages/demo-corefolder can not import files underapps(the viewer layer). -
The files in the
packages/demo-corefolder can not import lib that is platform-specific to web or native, for example:next,react-native. -
Folders in
appscan import anything in thepackages/demo-corefolder. -
For
appsviewer layer, don't recommend to import recoil state directly in thepackages/demo-corefolder, if we need some state managed by recoil but don't want to put it into thepackages/demo-core, we can put it in theappsfolder directly, in this way, we can not reuse the state crossing apps.
All the packages are hoisted to the root folder, which means the package will be installed in the root's node_modules rather the one under apps, the reason is that for some package, like react we can not separate (nohoist) it into both web and demo-core, if doing so, the app will throw error about react hook problem.
If there are some packages that we can separate/nohoist in the folder, for example, native, we can add the package into the root's package.json:
{
"workspaces": {
"packages": [
"apps/*",
"packages/*"
],
"nohoist": [
"**/react-native",
"**/react-native/**"
]
}
}