Closed sorokinvj closed 6 years ago
Oh I got it!
In case somebody is interested I just made everything in my action file: (don't pay attention to const changeLanguage, it is my old way of changing locale in order to get the right content from API)
import { SWITCH_LANGUAGE } from './action_types.js'
import { setLanguage } from "redux-i18n"
const changeLanguage = (language) => ({type: SWITCH_LANGUAGE, language })
export const switchLanguage = (language) => (dispatch) => {
dispatch(changeLanguage(language));
dispatch(setLanguage(language));
}
hi, I believe this is very stupid question from the very beginner (which I am), but I'm stuck, so please help!
In my component which is connect via connect() I initialize mapDispatchToProps in order to get access to actions:
However if import setLanguage and add it inside Object.assign nothing happens and I don't see setLanguage in my props, so this doesn't work:
However, I need to do it this way, I can't just use dispatch(setLanguage) because I don't have dispatch available at my props. Though if I delete mapDispatchToProps than I have dispatch available and everything works fine.
So how do I add setLanguage to my functions in mapDispatchToProps?