2

is there a way to use translate function of react-redux-localize inside the reducers?

import { getTranslate } from 'react-localize-redux';
import store from '../store';

export default function customReducer(
    state = {},
    action
) 
{
    let translate = getTranslate(store.getState().locale);
}
        

During that I'm getting: Error: You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.

important packages versions:

 "react-localize-redux": "^2.16.0",
 "react-redux": "^7.2.1",
 "redux": "^4.0.5",
 "react": "^16.12.0",

it's probably related topic to Accessing a reducer state from within another reducer but maybe there is other way to use translate function?

I know that there is a way to pass translate function in action but it doesn't look like good solution

wgrzesiak147
  • 143
  • 9

0 Answers0