last day (14 days later) » 

12:35 AM
0
Q: Link, activeClassName just plain not working

Craig WrightI cannot get activeClassName to work. activeClassName will always be assigned to the first route which was served by the server. So if it is /, Bets will be highlighted. It it is /about, About will be highlights. Assignation of activeClassName will never change past the initial page load. It is ...

 
What's your react and react-router versions?
 
react@0.14.8 react-router@2.4.1
 
Try removing the leading slash from your Links (not the IndexLink one)
 
I have indeed tried that, in fact the current code does not have those forward slashes. No help.
 
can you provide the value for this.props.route.path?
 
12:35 AM
Here is the whole object: "{"path":"/","indexRoute":{},"childRoutes":[{"path":"profile"},{"path":"profile‌​‌​/:userId"},{"path":"help"},{"path":"about"}]}"
 
I'm more interested in what it outputs when inside, say, "help"
 
Wow!
 
I think I know the answer, but just in case
 
I've never seen this chat interface. OK I'll go dig it up. One sec.
 
:)
 
12:37 AM
"{"path":"help"}"
 
ok so your paths were correctly set
hmm 1 sec
 
Good to know, good debugging tip.
 
I guess you could try and see if your Navigation component rerenders as it should. Either do a this.forceUpdate() or do a console.log inside the render method
it should rerender when you click a link
any luck?
 
12:53 AM
Ah sorry got distracted. Let me try
Nope, Navigation is not re-rendering
This debugging is very useful, I am very new to React.
Where would I put a "this.forceUpdate()", would something along those lines fix my issue?
Ah interesting. I see that "this.props.route" for Navigation is undefined. Thus, the props never change, thus it never re-renders.
Huuuuh. Maybe I could manually pass that from the parent component? Or is that a terrible hack?
 
Can you update your question and show where you use the Navigation component?
and yes, that's probably it
 
Sure. Let me try a few things and I'll update.
 
1:27 AM
OK I updated the question
 
1:39 AM
ok so just try and include react-router in your navigation. I think that should pass the props right.
 
OK
Just import... route?
 
no like import router from 'app/router' or whatever
 
Hmm
OK
I'll edit to include my whole Navigation file too
 
if I recall that should give the component the props it needs
 
No dice.
 
1:53 AM
I already noticed you had already imported it. I need some sleep :P
and its friday lol
but yeah the problem is most likely that your navigation component doesnt rerender and it should
you can test a force rerender just to double check that a rerender would fix this
just add a button or something that does this.forceUpdate() inside the nav component. That should set the correct styles if you are in "help" for example.
I'll look into this more tomorrow. its 4am over here lol
good luck
 
Cool thanks so much!
I really appreciate it.
 

last day (14 days later) »