我正在使用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')}>
现在我有一个班级,我有我所有的业务逻辑,我想用它来执行屏幕之间的导航,例如,我想验证用户,以防我想要更改屏幕。但这堂课没有道具,怎么办?