Introduction
The Router Package will
- Parse URL /Path
- Read Config
- Render / Load appropriate JSX / Component
Setup
npm install --save react-router-dom
1 | // App.js |
The attribute of the routing is also passed to the components in the props
. But the props
are not available in the nested components in route component.
1 | // Component.js |
1 | NavLink .my-active { |
Pass route parameters
1 | // Routing component |
Extract params from route
1 | componentDidMount() { |
Navigating Programmatically
1 | onClickHandler = (id) => { |