React Router v4 – How to get current route?

I’d like to display a title in <AppBar /> that is somehow passed in from the current route. In React Router v4, how would <AppBar /> be able to get the current route passed into it’s title prop? <Router basename=”/app”> <main> <Menu active={menu} close={this.closeMenu} /> <Overlay active={menu} onClick={this.closeMenu} /> <AppBar handleMenuIcon={this.handleMenuIcon} title=”Test” /> <Route path=”/customers” … Read more

Nested routes with react router v4 / v5

I am currently struggling with nesting routes using react router v4. The closest example was the route config in the React-Router v4 Documentation. I want to split my app in 2 different parts. A frontend and an admin area. I was thinking about something like this: <Match pattern=”https://stackoverflow.com/” component={Frontpage}> <Match pattern=”/home” component={HomePage} /> <Match pattern=”/about” … Read more

Programmatically navigate using react router V4

I have just replaced react-router from v3 to v4. But I am not sure how to programmatically navigate in the member function of a Component. i.e in handleClick() function I want to navigate to /path/some/where after processing some data. I used to do that by: import { browserHistory } from ‘react-router’ browserHistory.push(‘/path/some/where’) But I can’t … Read more

React Router with optional path parameter

I want to declare a path with an optional path parameter, hence when I add it the page to do something extra (e.g. fill some data): http://localhost/app/path/to/page <= render the page http://localhost/app/path/to/page/pathParam <= render the page with some data according to the pathParam In my react router I have the following paths, in order to … Read more

How to push to History in React Router v4?

In the current version of React Router (v3) I can accept a server response and use browserHistory.push to go to the appropriate response page. However, this isn’t available in v4, and I’m not sure what the appropriate way to handle this is. In this example, using Redux, components/app-product-form.js calls this.props.addProduct(props) when a user submits the … Read more