Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get url params inside a Redux middleware using React-router

I'd like to extract the URL params inside a Redux middleware in order to dispatch an action and use those values in the payload.

like image 999
haxpanel Avatar asked Jul 01 '16 08:07

haxpanel


1 Answers

In order to achieve your goal , you can use redux-router

This library allows you to keep your router state inside your Redux store. So getting the current pathname, query, and params is as easy as selecting any other part of your application state.

after that you can get your params from middleware

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

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

MORE INFO

like image 195
Kokovin Vladislav Avatar answered Nov 18 '22 12:11

Kokovin Vladislav