Question: Link to dynamic active class?

Question

Link to dynamic active class?

Answers 0
Added at 2017-01-02 14:01
Tags
Question

router for routing purpose in my react app.

Mine routing is defined in given manner:

<Route path={food/:cuisine/:pageNo} component={foodList}

and my navBar have following navigation:

<Link to={"/food/italian/1"} activeClassName="active">Italian</Link>
<Link to={"/food/indian/1"} activeClassName="active">Indian</Link>

but when visit page no. 2("/food/indian/2") of that component then myActive class of navBar is not showing. If there are any alternate method to solve this problem then it will be great.

Thanks.


PS: I don't want to put all conditions like because the app has more than 15 different cuisine

if(this.props.params.cuisine=="Indian){
    //then add .active in my Link to class
}

=======

Answers to

Link to dynamic active class?

Source Show
◀ Wstecz