项目作者: alande-amorim

项目描述 :
Demo Authentication app in React Native
高级语言: Java
项目地址: git://github.com/alande-amorim/react-native-auth.git
创建时间: 2020-04-24T20:29:42Z
项目社区:https://github.com/alande-amorim/react-native-auth

开源协议:

下载


React Native auth demo

About

This is a demo app to study and demonstrate the proper implementation of an authentication flow in React Native with Context API & Hooks.

This app was done by following RocketSeat‘s Masterclass #12.

Although there’s no real external API calls, just for the sake of simplicity I’m mocking an API call at the start of the sign in flow. The services/auth.tsx file mocks this request by returning the user object after a 2000 ms timeout (async).

Requirements

You need a React Native CLI development environment setup in order to try this app.

Installing & Running

Clone and install this repo:

  1. $ git clone https://github.com/alande-amorim/react-native-auth.git
  2. $ cd react-native-auth
  3. $ yarn install
  4. $ yarn start

Then launch this app on your emulator.

For me, I have to first open up the emulator and then:

  1. $ yarn android

Covered topics

  • Invoking the API
  • Retrieving token and user data
  • Persisting these data on AsyncStorage
  • Making these data available app wide using Context API
  • Passing the token on the authentication header during API calls
  • Creating Hooks
  • Handle loading states
  • Sign in and sign out flows
  • Setting up and using guest and auth routes