React Flux: Routing with react-router-component

InstructorJoe Maddalone

Share this video with your friends

Send Tweet

By default, React doesn't have built in routing. We will add routing to our application with the react-routing-component.

Delchina
~ 10 years ago

Tried code not working.

dave
~ 10 years ago

Hi

It doesn't look like the complete source code is available here.

dave
~ 10 years ago

the following link might be useful, github.com/STRML/react-router-component/issues/32; But I cannot fix the error. Could someone at egghead look into this please , I really enjoy these videos and want to learn more about routing

dave
~ 10 years ago

And yes I am running the source code

dave
~ 10 years ago

OK I found my error, I was being lazy and opening dist/index.html in browser. For anyone else stuck like I was install a command line server e.g. npm install --save-dave http-server ( or one of your choice) cd to dist directory at prompt type 'http-server' to start server should listen on port 8080 In browser go to http://localhost:8080

Stephen
~ 10 years ago

Awesome, and thank you. I can only guess how many hours this saved me.

Nicolas
~ 9 years ago

I've been having the same issue as Jason. I followed the lesson step by step and can't get it to serve up. I get this:

Uncaught TypeError: Cannot read property 'props' of undefined

from my main.js file

Any help would be awesome. Thx guys!

Faria Chowdhury
~ 9 years ago

edit...nevermind. I needed to run the http server from within the dist/ directory so that the urls match the actual routes.

I'm getting the error: Uncaught TypeError: Cannot read property 'ref' of null from main.js:1177 which is in RouteRenderingMixin: props = assign({ref: this.state.match.route.ref}, props);

However, if I comment out the line {this.props.children} in app-template.js, then I don't get any errors, and I can see the Header and CartSummary components are rendered.

Darren Corbett
~ 9 years ago

Dave you're a star was just about to throw a fit coz I couldn't get this bit to work....

thanks Darren

Nick
~ 9 years ago

Thank you- I have been doing the same throughout the tutorials up until now. One thing I haven't been able to figure out though, is why my paths are not matching. Did you run into this as well?

Nick
~ 9 years ago

I can't remove my own post, so I might as well post the solution:

I was running http-server from my (project)root folder. Should have started it in the /dist folder.