javascript – react-router链接在上下文中没有接收路由器

栏目: 服务器 · 发布时间: 7年前

内容简介:翻译自:https://stackoverflow.com/questions/30947518/react-router-link-not-receiving-router-in-context
我正在使用React和react-router来创建单页面的 javascript

应用程序.每个页面都是它自己的组件.在一个页面上,我能够成功创建一个链接组件,它可以按预期工作.在另一个页面上,我收到以下错误:

Warning: Failed Context Types: Required context `router` was not specified in `Link`.
Uncaught TypeError: Cannot read property 'makeHref' of undefined

这是我设置路线的文件:

http://pastebin.com/WBeN9BZw

以下是链接工作的组件(在TeamRow组件中):

http://pastebin.com/HjG2d43M

这是链接不起作用的组件(第31行):

http://pastebin.com/pWb7j8Mk

我在整个应用程序中记录了上下文以检查它们,并且它唯一不是空对象的时间在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

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》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具