这是来自文档的示例 - nextState
从哪里来?React Router getComponents中的nextStater是什么,它来自哪里?
<Route path="courses/:courseId" getComponents={(nextState, cb) => {
// do asynchronous stuff to find the components
cb(null, {sidebar: CourseSidebar, content: Course})
}} />
谢谢@yury!一个问题,你为什么使用'location'?为什么它不只是'nextState.query.form'?是因为你从链接中获得道具吗?你还能从哪里得到道具? – mangocaptain
我只是为了演示而使用它。有更好的方法来获取组件中的查询参数,而不是使用'withRouter'。但是当你需要基于这些参数异步加载组件时,你必须这样做。顺便提一下,你应该记住'getComponent'在react-router v4中被删除了。 –