Skip to content

activeClassName not being set #1058

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

Closed
pavanpodila opened this issue Apr 9, 2015 · 4 comments
Closed

activeClassName not being set #1058

pavanpodila opened this issue Apr 9, 2015 · 4 comments

Comments

@pavanpodila
Copy link

Here is my route config:

var routes = (
    <Route handler={App}>
        <DefaultRoute name="index" handler={Dashboard}/>
        <Route name="dashboard" handler={Dashboard}/>
        <Route name="projects" handler={Projects}/>
        <Route name="people" handler={People}/>
        <Route name="planning" handler={Planning}/>
        <Route name="reports" handler={Reports}/>
        <Route name="profile" handler={Profile}/>
    </Route>
);

I am not sure what I am doing wrong, but I don't see the active class being set on my <Link />s.

Here is one of my links pointing at dashboard:

                        <li>
                            <Link to="dashboard">Dashboard</Link>
                        </li>
@pavanpodila
Copy link
Author

Sorry, this is working. I was using this with Bootstrap which expects the active class to be set on the <li> instead of the <a> inside the <li>.

<Link> is setting it on the inner <a>, which is why there was no visual feedback on this. Not sure how I can fix this, but at least this is working from the router side.

False alarm.

@pavanpodila
Copy link
Author

Also, I could fix the Bootstrap issue by taking cues from this issue.

@durban89
Copy link

i have a solution:

render: function () {
  let route = this.props.children.type.name.toLowerCase();

  let homeActive = (route == 'home') ? 'active' : '';
  let profileActive = (route == 'profile') ? 'active' : '';
  let messageActive = (route == 'message') ? 'active' : '';

  return (
    <div className='col-md-12'>
      <div className='row'>
        <ul className="nav nav-tabs">
          <li role="presentation" className={homeActive}>
            <Link to='/diagramShow/home'>Home</Link>
          </li>
          <li role="presentation" className={profileActive}>
            <Link to='/diagramShow/profile'>Profile</Link>
          </li>
          <li role="presentation" className={messageActive}>
            <Link to='/diagramShow/message'>Message</Link>
          </li>
        </ul>
      </div>
      <div className='row'>
        <div className='col-md-12'>
          {this.props.children}
        </div>
      </div>
    </div>
  );
}

@knowbody
Copy link
Contributor

what is the point of commenting on the issue from April?

@lock lock bot locked as resolved and limited conversation to collaborators Jan 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants