React Flux: Routing with react-router-component

Joe Maddalone
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
Delchina
~ 6 years ago

Tried code not working.

dave
dave
~ 6 years ago

Hi

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

dave
dave
~ 6 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
dave
~ 6 years ago

And yes I am running the source code

dave
dave
~ 6 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
Stephen
~ 6 years ago

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

Nicolas
Nicolas
~ 6 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
Faria Chowdhury
~ 6 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
Darren Corbett
~ 6 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
Nick
~ 5 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
Nick
~ 5 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.