内容简介:翻译自:https://stackoverflow.com/questions/30947518/react-router-link-not-receiving-router-in-context
应用程序.每个页面都是它自己的组件.在一个页面上,我能够成功创建一个链接组件,它可以按预期工作.在另一个页面上,我收到以下错误:
Warning: Failed Context Types: Required context `router` was not specified in `Link`. Uncaught TypeError: Cannot read property 'makeHref' of undefined
这是我设置路线的文件:
以下是链接工作的组件(在TeamRow组件中):
这是链接不起作用的组件(第31行):
我在整个应用程序中记录了上下文以检查它们,并且它唯一不是空对象的时间在App组件中.在我的链接不起作用的TeamPage组件中我做错了什么?为什么HomePage组件中的上下文为空,但链接有效?
尝试将您的要求更改为
// remove the react-router require
var {Link} = require('react-router');
要么
// keep the react-router require var Link = ReactRouter.Link;
翻译自:https://stackoverflow.com/questions/30947518/react-router-link-not-receiving-router-in-context
以上所述就是小编给大家介绍的《javascript – react-router链接在上下文中没有接收路由器》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
How to Think Like a Computer Scientist: Learning with Python
Allen B. Downey、Jeffrey Elkner、Chris Meyers / Green Tea Press / 2002-1-4 / USD 24.95
""How to Think Like a Computer Scientist"" is an introduction to programming using Python, one of the best languages for beginners. This is a Free Book -- you can download it from thinkpython.com. But......一起来看看 《How to Think Like a Computer Scientist: Learning with Python》 这本书的介绍吧!