我正在使用 NavigatorIOS,当我传递给初始路由的 Prop 发生变化时,我试图通过重置为您在下面使用“componentWillReceiveProps”中新更新的 Prop 找到的组件来更新它们。
componentWillReceiveProps: function(nextProps) {
this.refs.navigator.resetTo({
title: 'Home',
component: search,
backButtonTitle: 'Back',
passProps: {
api: nextProps.api,
slug: nextProps.slug
}
});
}
我很确定我没有正确引用路线,但坦率地说,我还没有找到任何关于这个问题的有用资源。
Replace() 完成更新 Prop 的工作,但我也希望它到 popToTop()。 Replace 和 ResetTo 都采用路由对象,所以我不明白为什么 replace() 有效并且 resetTo() 给我这个错误。
这是我的 NavigatorIOS:
<NavigatorIOS
ref='navigator'
initialRoute={
{
title: 'Home',
component: search,
backButtonTitle: 'Back',
passProps: {
api: this.props.api,
slug: this.props.slug
}
}
}
/>
最佳答案
如果你声明如下:
var routes = this.refs.navigator.getCurrentRoutes();
然后你可以像这样弹出一个路由:
this.refs.navigator.popToRoute(routes[1]);
关于javascript - 不变违规 : Calling pop to route for a route that doesn't exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31320583/