Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

React-Native Monorepo: SimpleRouting

License

Notifications You must be signed in to change notification settings

ottograjeda/t-524-SimpleRouting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 

Repository files navigation

React-Native Monorepo: SimpleRouting

"SimpleRouting" is sample code of routing and navigation for web or app platforms.

This is upgrade work to another monorepo. The repos are examples for how to share code between different platforms (Web, Android, & iOS). They can be used as a template or starter-kit for React-Native & React-Native-Web. 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.

Installation

  • Get the repo
  • From root directory, do yarn
  • Change root/android/local.properties as needed
  • From root/ios directory, do pod install (if needed)

Required: React-Native working per Getting Started. If using React-Native ^0.60 , make sure
you review the blog post & use the upgrade guide. As notes in those links, update these files

  • Change root/android/build.gradle as needed
  • Change root/android/app/build.gradle as needed
  • Change root/android/gradle.properties as needed
  • etc

Run

For each platform, from the root directory, do

Web

  • 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

Android

  • react-native run-android -- --clear-cache

iOS

  • react-native run-ios or open ios/SimpleRouting.xcodeproj with Xcode

Screenshots & Animated GIFs

Screenshot - all Animated GIF - iOS Animated GIF - Andoid

Notes - Development

  • React Router aka 1 package is used as navigational components
  • Error handling for missing routes, aka 404 pages, left as exercise to repo user. You can use this guide, if stuck.

Notes - Miscellaneous

  • To make code simple, Redux is omitted. No state is needed.
  • Lerna or Yarn Workspaces is not used ; there is only 1 node_modules folder.

Inspiration