company-auth-app
TypeScript icon, indicating that this package has built-in type declarations

1.0.8 • Public • Published

Como adicionar esta lib ao seu projeto

passo 1 - Instalação

Se você usa yarn

$ yarn add company-auth-app

Se você usa npm

$ npm i company-auth-app

passo 2 - Adicionar o stack de navegação na root

Se você criou o seu projeto com o nosso CLI, execute os seguintes passos

Adicionar como TAB na root

  • Abra o arquivo App.tsx (arquivo se encontra no root do projeto) e adicione o seguinte código:

    $ return (
      <AppRoot store={store} theme={theme} themeMode="light">
        <AuthSwitchStackNavigator
          theme={theme}
          themeMode="light"
          initialRouteName="SEU_INITIAL_ROUTE_NAME">
          <BottomTab.Screen
            name="SEU_ROOT_NAVIGATOR_TAB_NAME"
            component={SEU_ROOT_NAVIGATOR}
            options={{
              tabBarIcon: ({color}) => (
                <TabBarIcon name="..." color={color} />
              ),
            }}
          />
        </AuthSwitchStackNavigator>
      </AppRoot>
    );
    

passo 3 - Adicionar o store

  • Abra o arquivo src/store/epics.tsx e adicione o seguinte código:

    $ export const rootEpic = combineEpics(
    [...]
    authEpics,
    [...]
    );
    
  • Abra o arquivo src/store/index.tsx e adicione o seguinte código:

    $ const rootReducer = combineReducers({
    [...]
    auth: authSlice.reducer,
    [...]
    });
    
    

API

Obter o usuário logado (Class Components)

 const mapStateToProps = (state: AuthState) => {
  const user = authSelectUser(state);
  return {user};
}; 

Fazer logout (Class Components)

const mapStateToDispatch = (disptach: any) => {
  return {logout: () => disptach(authLogout())};
};

Pronto.

Readme

Keywords

none

Package Sidebar

Install

npm i company-auth-app

Weekly Downloads

6

Version

1.0.8

License

none

Unpacked Size

63.8 kB

Total Files

48

Last publish

Collaborators

  • patriciocordeiro