Skip to content

Replace usage of withRouter with router information that is already available via Redux #496

@davemcorwin

Description

@davemcorwin

We are currently using connected-react-router which maintains up-to-date router information in the Redux store so getting access to this information is the same as for any other data in Redux. This eliminates the need to use withRouter to get access to this data.

All data is currently available under the router key in the Redux store, Ex:

import React from 'react';
import { connect } from 'react-redux';

export const MyComponent = ({ currentPath }) => <div>{currentPath}</div>;

const mapStateToProps = ({ router }) => ({
  currentPath: router.location.pathname
});

export default connect(mapStateToProps)(MyComponent);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions