Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-router link not receiving router in context

I'm using React and react-router to create a single page javascript application. Each page is it's own component. On one page I am able to create a Link component successfully and it works as intended. On another page I get the following error:

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

Here is the file where I set up my routes:

http://pastebin.com/WBeN9BZw

Here is the component where the link works (in the TeamRow component):

http://pastebin.com/HjG2d43M

Here is the component where the link doesn't work (line 31):

http://pastebin.com/pWb7j8Mk

I logged the contexts throughout the app to examine them and the only time it isn't an empty object is in the App component. What am I doing wrong in the TeamPage component that my Link isn't working? How come the context is empty in the HomePage component but the Link works?

like image 245
Liam Avatar asked Jun 19 '15 21:06

Liam


1 Answers

Try changing your require to

// remove the react-router require
var {Link} = require('react-router');

or

// keep the react-router require    
var Link = ReactRouter.Link;
like image 137
BradByte Avatar answered Oct 04 '22 22:10

BradByte