【发布时间】:2020-08-19 15:42:52
【问题描述】:
当前行为
我使用反应导航 v4x undefined 不是对象 navigation.discpatch
预期行为
我想在 appcontainer 中导航登录页面 `
export default class App extends Component {
constructor(props) {
super(props);
this.state = {isFirstLaunch: false, hasCheckedAsyncStorage: false};
const myRef = createRef();
}
onPressLogin() {
this.navigator.dispatch(
NavigationActions.navigate({ routeName: 'Login' })
);
}
async componentDidMount() {
const isFirstLaunch = await checkIfFirstLaunch();
this.setState({isFirstLaunch, hasCheckedAsyncStorage: true});
}
render() {
const {hasCheckedAsyncStorage, isFirstLaunch} = this.state;
if (!hasCheckedAsyncStorage) {
return null;
}
return isFirstLaunch ? (
<EntryInfo onPress={this.onPressLogin} />
) : (
<AppContainer
ref={nav => {
setTopLevelNavigator(nav);
this.navigator = nav;
}}
/>
);
}
}`
软件版本安卓 反应导航 4.4.0 反应导航堆栈 2.8.2 反应原生 0.62.2
【问题讨论】:
-
我试图解决,但没有奏效:/
-
您的代码似乎没有遵循指南...
-
_navigationService.default.navigate 不是对象
-
您能发布完整的 app.js 和 NavigationService 吗?
标签: react-native react-navigation react-navigation-stack