1
resposta

React Navigation V2

Salve galera, o meu grande problema está nessa v2 do React Navigation, dá tela branca, se eu tento fazer algo parecido com o video:

Eu não tenho acesso daquele ''component'' dentro da função ''registerAppLaunchedListener"

Se eu dou um console ali, não consigo acessar o dado ''component" então logicamente não consigo fazer a transição dos components.

Segue o código:

/**
 * @format
 */
import { Navigation } from 'react-native-navigation';
import AsyncStorage from '@react-native-community/async-storage';
import Login from './src/components/Login';
import App from './App';

Navigation.registerComponent('Login', () => Login);
Navigation.registerComponent('Feed', () => App);

AsyncStorage.getItem('token')
  .then(token => {
    if (token !== null) {
      return {
        name: 'Feed',
        options: {
          topBar: {
            title: {
              text: 'Feed'
            }
          }
        }
      };
    } else {
      return {
        name: 'Login',
        options: {
          topBar: {
            title: {
              text: 'Login'
            }
          }
        }
      };
    }
  })
  .then(component => {
    Navigation.events().registerAppLaunchedListener(() => {
      Navigation.setRoot({
        root: {
          stack: {
            children: [
              {
                component: component
              }
            ]
          }
        }
      });
    });
  });
1 resposta

Oi Erik, tudo bem ?

Vi que sua dúvida é um pouco antiga, será que tu resolveu ? Se sim pode compartilhar conosco ?

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software