Accessing store data in a react-redux application

Provided you have a react application based on the redux architecture, sometimes you might need to access information inside the store with a function, not necessarily using a component.

An example of such a need would be a function to get the rights of the authenticated used in order to build the interface components.

Here is an example of such a function:

import store from '../store.js';

const rights = (type) => {
    let state = store.getState();
    return state.auth || {};
}

store.subscribe(rights);
export default rights;Code language: JavaScript (javascript)