selected css based on route react

Solutions on MaxInterview for selected css based on route react by the best coders in the world

showing results for - "selected css based on route react"
Anaelle
06 Sep 2019
1// do something when clicking on route 
2
3function handler() {
4  // do something;
5}
6
7<Route path='/' component={App}>
8  <Route path="foo" component={Foo} onEnter={handler}/>
9  <Route path="life" component={Life} onEnter={handler}/>
10</Route>
11
Lennart
03 Apr 2016
1// user NavLink for conditional route styling
2
3const Router = () => (
4  <BrowserRouter>
5    <div>
6      <Nav>
7        <NavLink exact={true} activeClassName='is-active' to='/'>Home</NavLink>
8        <NavLink activeClassName='is-active' to='/about'>About</NavLink>
9      </Nav>
10
11      <Match pattern='/' exactly component={Home} />
12      <Match pattern='/about' exactly component={About} />
13      <Miss component={NoMatch} />
14    </div>
15  </BrowserRouter>
16)
17