Original concept of this boilerplate is from Ignite. We're really like the project structure from Ignite Boilerplate But we wanted to do things a little different. this Boilerplate will not create a new project based off of a template. Instead it will create a brand new React-Native app, then copy in the folder structure and install all the lastest version of the dependancies.
T29-RN include the following rock-solid technical decisions out of the box:
- React Native
- React Navigation 5
- OsmiCSX
- Reactotron-ready
- React Native Dotenv
- TDD-ready (COMMING SOON)
- And more!
Prerequisites:
- Make sure you already setup React Native environtment (Android SDK, Java, etc.). See React Native docs
Install Global CLI: (COMING SOON)
- Until the package is publish to the npm repository, you can download the repo. Cd into the repo directory and
npm install
. Then runnpm link
to install the package globally. If you want to remove the package you have runnpm unlink
from within the repo directory.
Run the CLI:
rn new MyApp
you can overwrite a directory by adding the --overwrite
flag. More flags will be added over time.
there are mulitple alias for creating a new app you can use create, create-app, new
.
And T29-RN will walk you through the rest.
One of the great features of T29-RN is the ability to quickly generate some template files. By runing rn g component NameOfComponent
T29-RN will create a file inside the components folder and pre-polutate it with a basic sturcture.
There are mulitple alias that you can use for the generator g, gen, generator, generators
.
The current generator templates that T29-RN has
- Component
- Screens
- Navigation Stack
- Navigation Tabs
- Redux toolkit Api Slice
- Redux Toolkit Slice
More to be added over time.
Your App
folder is where most of the goodies are found in an t29-RN app. Let's walk through them in more detail. Start with Containers/App.js
(described below) and work your way down the walkthrough in order.
Containers are (mostly) full screens, although they can be sections of screens or application containers.
App.js
- your main application. We create a Redux store and configure it hereRootContainer.js
- main view of your application. Contains your status bar and navigation componentScreens/LaunchScreen.js
- this is the first screen shown in your application. It's loaded into the Navigation componentScreens/WelcomeScreen.js
- this screen demenstrates a working RTK Query. It's loaded into the Navigation component
To generate a new Container or Screen you can use the following generator commands:
rn g screen TestScreen
- Will create aTestScreen.js
inside the Containers/Screen directory.
Your primary and other navigation components reside here.
AppNavigation.js
- loads in your initial screen and creates your menu(s) in a StackNavigation
rn g stack Test
- Will create aTestStack.js
inside the Navigation directory.
rn g tabs Test
- Will create aTestTabs.js
inside the Navigation directory.
React components go here...pretty self-explanatory. We won't go through each in detail -- open each file to read the comments and view the code.
To generate a new Component you can use the following generator commands:
rn g component Button
- Will create aButton.js
inside the Components directory.
Styling themes used throughout your app styles. Since we're using OsmiCSX for the styling framework, OsmiProvider
and CustomTheme
goes here.
CustomTheme.js
- Apps custom theme.OsmiProvider.js
- Provider of OsmiCSX.
Initialize and configure things here.
DebugConfig.js
- define how you want your debug environment to actReactotronConfig.js
- configures Reactotron in your project.
Contains a preconfigured Redux and Redux ToolKit setup. Review each file carefully to see how Redux interacts with your application.
Here again we have generators to help you out. You just have to use one of the following:
rn g slice Amazing
- Will generate a redux slice forAmazing
.
Contains your API service and other important utilities for your application.
-
pokemon.js
- is just an example of how to setup a RTK Query slice. -
rn g api Amazing
- Will generate RTK QUERY forAmazing
.
We recommend using this folder for modules that can be extracted into their own NPM packages at some point.
Contains actual images (usually png) used in your application.
This folder (located as a sibling to App
) contains sample Jest snapshot and unit tests for your application.
If you found that the boilerplate is not installer properly on your React Native proect app. Usually it's because you already install the react-native-cli globally, to solve this try to run :
npm uninstall -g react-native-cli
Special thanks to Infinite Red who create such as beautiful react-native boilerplate (Ignite CLI). And give the inspiration for me to create this alternative cli and boilerplate.