React Native Boilerplate
This project is a React Native boilerplate that can be used to kick-start a mobile application.
The boilerplate provides an architecture optimized for building solid cross-platform mobile applications through separation of concerns between the UI and business logic. We made this full documentation so that each piece of code that lands in your application can be understood and used.
Don't forget !!
If you love this boilerplate, give us a star, you will be a ray of sunshine in our lives ๐ โ๏ธ
Architecture
The driving goal of the architecture of the boilerplate is separation of concerns and using React Native at its best.
Using modern Javascript So many javascript features are indispensable now like hooks, functional component and really cool dependencies.
Presentational components are separated from containers.
Presentational components are small components that are concerned with how things look. Containers usually define whole application screens and are concerned with how things work: they include presentational components and wire everything together.
If you are interested you can read more about it here.
State is managed using global Redux stores.
When applications grow, sharing state and its changes can become very hard. Questions like "How can I access this data?" or "When did this change?" are common, just like passing data around components just to be able to use it in nested components.
With Redux, state is shared using global stores, and changes are predictable: actions are applied by reducers to the state. While the pattern can be a bit much for small projects, the clear separation of responsibilities and predictability helps with bigger applications.
If you are interested you can read more about it here.
Content
The boilerplate contains:
- a React Native (v0.63.3) application (in "ejected" mode to allow using dependencies that rely on native code)
- a clear directory layout to provide a base architecture for your application
- Redux (v4.0.5) to help manage state
- Redux Persist (v6.0.0) to persist the Redux state
- React Navigation (v5) to handle routing and navigation in the app, with a splash screen setup by default
- redux toolkit (v1.4.0) to make redux easier
- axios (v0.20.0) to make API calls
- prettier and eslint preconfigured for React Native
- react-native-flipper (v0.62.0) to debug react-native and redux-flipper (v1.3.2) to debug redux
The boilerplate includes an example (displaying fake user data) from UI components to the business logic. The example is easy to remove so that it doesn't get in the way.
Directory layout
src/Assets
: assets (image, audio files, ...) used by the applicationsrc/Components
: presentational componentssrc/Config
: configuration of the applicationsrc/Constants
: configuration of the applicationsrc/Helpers
: helpers of the applicationsrc/HOC
: Higher-Order Componentssrc/Hooks
: custom hookssrc/Navigation
: app main navigationsrc/Reducers
: app reducerssrc/Routes
: app routessrc/Screens
: app screenssrc/Services
: application services, e.g. API clientssrc/Store
: redux storessrc/Translations
: application translatesrc/Theme
: base styles for the application
Updates
The boilerplate will follow new React-Native releases as soon as libraries and tools used here are compatible.