我正在尝试在React Native中从登录屏幕导航到仪表板屏幕。
但是,它抛出了下面的错误。
Must use destructuring props assignment [react/destructuring-assignment]我的代码是
loginMethod() {
//some code
if (Success) {
this.props.navigator.push({
Component: Dashboard
});
this.state.props.navigator.immediatelyResetRouteStack([{
Component: Dashboard
}]);
}
}我是非常新的React Native,有什么建议吗?
发布于 2019-01-22 14:24:26
这是一个ESLint错误。您可以通过将navigator提取到单独的变量中来修复它。
loginMethod() {
//some code
if (Success) {
const { navigator } = this.props;
navigator.push({
Component: Dashboard
});
}
}这应该可以修复您的错误。
发布于 2019-01-22 14:25:16
这是一个eslint错误。你需要修改你的代码。使用解构
loginMethod() {
//some code
if (Success) {
// using destructuring
const {navigator} = this.props;
navigator.push({
Component: Dashboard
});
navigator.immediatelyResetRouteStack([{
Component: Dashboard
}]);
}
}https://stackoverflow.com/questions/54302281
复制相似问题