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链接在上下文中没有接收路由器》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Using Google App Engine

Using Google App Engine

Charles Severance / O'Reilly Media / 2009-5-23 / USD 29.99

With this book, you can build exciting, scalable web applications quickly and confidently, using Google App Engine - even if you have little or no experience in programming or web development. App Eng......一起来看看 《Using Google App Engine》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

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

RGB HEX 互转工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换