他们从哪里获得路由器上下文
Where did they get the router context
在 react-router
的示例文件夹中,他们从哪里获得 Login.js
上的 router 上下文。我对此很困惑。作为参考,这里是 link for the Login.js file.
我没有在 router 上看到任何变量声明。
RouterContext
有 childContextType
router
https://github.com/rackt/react-router/blob/master/modules/RouterContext.js#L36
childContextTypes: {
history: object,
location: object.isRequired,
router: object.isRequired
},
而 login.js
有这个。
contextTypes: {
router: React.PropTypes.object
},
这是基于Context
在 react-router
的示例文件夹中,他们从哪里获得 Login.js
上的 router 上下文。我对此很困惑。作为参考,这里是 link for the Login.js file.
我没有在 router 上看到任何变量声明。
RouterContext
有 childContextType
router
https://github.com/rackt/react-router/blob/master/modules/RouterContext.js#L36
childContextTypes: {
history: object,
location: object.isRequired,
router: object.isRequired
},
而 login.js
有这个。
contextTypes: {
router: React.PropTypes.object
},
这是基于Context