Created following the tutorial of Rocketseat available on Youtube: # Autenticação no React Native / ReactJS com Context API & Hooks | Masterclass #12 by Diego Fernandes
Using that beatiful thing called Context API.
Create a custom hook for authentication.
context api, react native with context api, reactjs with context api,
- When the page or app is closed and reopened a function on AuthContext will verify if have information stored and will rehydrate the user state then it will Sign In automatically, or Sign Out if no information was found.
Web | Mobile |
---|---|
- Clone this repo to your local machine using
https://github.com/lucaswilliameufrasio/auth-contextapi-hooks.git
git clone https://github.com/lucaswilliameufrasio/auth-contextapi-hooks.git ./FOLDER_NAME
Navigate to project's folder and install packages
$ cd FOLDER_NAME/web
$ yarn
Run the application with
$ yarn start
Open http://localhost:3000 on your favorite browser
Navigate to project's folder and install packages
$ cd FOLDER_NAME/mobile
$ yarn
Run the application with
$ yarn android
Open another terminal window on mobile folder an run the metro bundler with
$ yarn start
- Why to use Context API instead of Redux?
- When you don't need a time traveling debugger, as known as Redux DevTools, or custom middlewares.
Reach out to me at one of the following places!
- LinkedIn at
linkedin.com/in/lucaswilliameufrasio/