Get url parameters inside Redux middleware using React-router

I would like to extract the URL parameters inside the Redux middleware in order to submit the action and use these values ​​in the payload.

+4
source share
2 answers

To achieve your goal you can use redux-router

This library allows you to save the state of your router in your Redux repository. Thus, retrieving the current path, query, and parameters is as simple as selecting any other part of your application state.

export const someMiddleware = store => next => action=> {
    /// get params
    let params = store.getState().router.params;

    ///then do what you want...........
    next(action)
};

+2

params . params props , .

- :

this.props.dispatch(yourAction(this.props.params));

, dispatch - Connect. :

export default connect()(YourComponent);
+1

All Articles