更改没有道具的类中的屏幕

时间:2018-06-14 18:17:18

标签: react-native react-navigation

我正在使用react-navigation,将其设置在我的app.js

import React, { Component } from 'react';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import ReduxThunk from 'redux-thunk';

import { createStackNavigator } from 'react-navigation';
import reducers from './src/reducers';


import firebase from 'firebase';

import FormLogin from "./src/components/FormLogin";
import FormCadastro from "./src/components/FormCadastro";
import FormBoasVindas from "./src/components/BoasVindas";
import FormPrincipal from "./src/components/Principal";

const AppNavigator = createStackNavigator({
  FormLoginScreen: { screen: FormLogin },
  FormCadastroScreen: { screen: FormCadastro },  
  FormBoasVindasScreen: { screen: FormBoasVindas }, 
  FormPrincipalScreen: { screen: FormPrincipal },
});

type Props = {};
export default class App extends Component<Props> {

  render() {
    return (
      <Provider store={createStore(reducers, {}, applyMiddleware(ReduxThunk))}>
        <AppNavigator />
      </Provider>
    );
  }
}

当我将导航与按钮相关联时,例如它完美地运行

 <Button onPress={() => this.props.navigation.navigate('FormCadastroScreen')}>

现在我有一个班级,我有我所有的业务逻辑,我想用它来执行屏幕之间的导航,例如,我想验证用户,以防我想要更改屏幕。但这堂课没有道具,怎么办?

0 个答案:

没有答案