Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Active routes not changing #4

Closed
agharsallah opened this issue Nov 22, 2016 · 1 comment
Closed

Active routes not changing #4

agharsallah opened this issue Nov 22, 2016 · 1 comment

Comments

@agharsallah
Copy link

agharsallah commented Nov 22, 2016

when adding a new link to the tab and activeClassName to the Link element the style dose'n apply unless I press refresh.
I've added {pure:false} to connect but the same problem persists : remix-run/react-router#3536

@DimiMikadze
Copy link
Owner

Hey, sorry for late answer.

I don't know why activeClassName is not working, in my latest project i'm comparing props.location.pathname and based on that toggling active class.

  componentWillReceiveProps(nextProps) {
    if (this.props.currentUrl !== nextProps.currentUrl) {
      this.setState({ activeUrl: nextProps.currentUrl });
    }
  }

render

  <li className={this.state.activeUrl === '/' ? 'Navigation__active' : ''}>
      <Link to="/">Home</Link>
 </li> 

let me know, if you still have difficulties with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants