Initial Setup
Starter base
A starting point to help you set up your project quickly and use the common components provided by react-native-reusables
. The idea is to make it easier for you to get started.
Installation
- Clone the
react-native-reusables
repository
- Use the following bash command and rename
my-project
to the name of your new project.
This will copy the folder
react-native-reusables/apps/starter-base
, paste it as a sibling, and rename it to your new project name.
- Change Directory to your project (replace
my-project
with your project’s name), install the dependencies, and fix packages if needed.
- Run the project
- Change Directory to your project (replace
my-project
with your project’s name), install the dependencies, and fix packages if needed.
- Run the project
- Change Directory to your project (replace
my-project
with your project’s name), install the dependencies, and fix packages if needed.
- Run the project
Install NativeWind
Follow the installation guide for NativeWind from the official documentation
Dependencies and utilities
- Install the following packages:
Platforms: Web, iOS, and Android
Platforms: iOS and Android
- Configure path aliases
We use the ~
alias. This is how you can configure it in your tsconfig.json
file:
- Add a cn helper
Add the following code to the ~/lib/utils.ts
file:
- Add the useColorScheme hook
Add the following code to the ~/lib/useColorScheme.tsx
file:
Add CSS variables
- Add the following css variables to
~/global.css
file.
- Add the following code in the
~/lib/constants.ts
file for the navigation theme colors:
If you changed the colors in the ~/global.css
file, update the ~/lib/constants.ts
file with the new colors.
Each color has a commented css variable name next to it.
Configure colors
- Use the CSS variables in your tailwind.config.js file.
Platforms: Web, iOS, and Android
Platforms: iOS and Android
- Configure React Navigation Theme
In your root component (ex: the root _layout.tsx
if you’re using expo-router), add the following code
to load the selected theme, prevent the flash of the default theme,
and store the selected theme in the async storage.
Install and Set Up Icons
- Install the following packages:
- Resolve the className strings into icon styles
Add the iconWithClassName
function in the ~/lib/icons/iconWithClassName.ts
file.
- Create the Icon files for switching between light and dark mode
Create ~/lib/icons/Sun.tsx
Create ~/lib/icons/MoonStar.tsx