0
我通过创建待办事项列表来学习反应。这些清单是按项目组织的。所以我有一个projects
数组和一个lists
对象。 { 项目:store.projects, 名单:store.lists }有没有办法改变反应路由器上的商店更改?
名单会是这个样子{projectName: ['list1',...]}
我的路线是无论我有projects
阵列
const routes = ({
var children = this.props.projects;
const routes = {
path: '/',
component: Nav,
indexRoute: { component: Layout },
childRoutes: [ ]
}
for(let i in children){
routes.childRoutes.push({path: children[i], component: Layout})
}
return routes
})
class Routing extends React.Component{
render(){
return(<Router className="row" routes={routes} history={browserHistory} />)
}
}
在到现在为止还挺好。现在,如果我发送一个动作,将一个项目推入我的projects
,我收到此错误消息:
警告:[react-router]您无法更改;它将被忽略
有没有办法让路由器每次我添加一些项目时都会重新创建this.props.projects
您执行此操作的方式是错误的,下面的@gravityplanx答案是继续前进的正确方法。 –