How to sync Redux state and url query params

I would suggest just using React Router directly and not keeping searchState in Redux. React Router will inject URL parameters into your components, and you can use them in mapStateToProps(state, ownProps) to calculate the final props. If you really want to see route changes as actions, you can use react-router-redux for two-way syncing, but it … Read more

React-Bootstrap link item in a navitem

Using LinkContainer from react-router-bootstrap is the way to go. The following code should work. import { Route, RouteHandler, Link } from ‘react-router’; import AuthService from ‘../services/AuthService’ import { Button, Nav, Navbar, NavDropdown, MenuItem, NavItem } from ‘react-bootstrap’; import { LinkContainer } from ‘react-router-bootstrap’; /// In the render() method <Nav pullRight> <LinkContainer to=”/home”> <NavItem eventKey={1}>Home</NavItem> </LinkContainer> … Read more

How to get query parameters in react-router v4

The ability to parse query strings was taken out of V4 because there have been requests over the years to support different implementation. With that, the team decided it would be best for users to decide what that implementation looks like. We recommend importing a query string lib. Here’s one that I use const queryString … Read more

How to test components using new react router hooks?

Edit: The proper way of doing this the way described in Catalina Astengo’s answer as it uses the real router functionality with just the history/routing state mocked rather than mocking the entire hook. The way I ended up solving it was by mocking the hooks in my tests using jest.mock: // TeamPage.test.js jest.mock(‘react-router-dom’, () => … Read more