Conditionally set active class on menu using react router current route. It doesn’t look like you’re passing the prop into the correct element. The children of App would be whatever child route is being rendered (so either Home or Triangles), but you want the prop to be passed to Menu.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | import React, {Component} from 'react'; import Menu from './menu'; export default class App extends Component { render() { return ( <div> <Menu location={this.props.location} /> <div className="jumbotron"> {this.props.children} </div> </div> ); } }; |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.