APSL / redux-i18n

A simple and powerful package for translate your react applications using react-redux.
MIT License
233 stars 52 forks source link

override the default state #98

Open flynorc opened 5 years ago

flynorc commented 5 years ago

Is there a way to simply override the default i18nState values when initializing the reducer?

I would need to override the lang property of it based on another value stored in a configuration file.

i've found this in the docs, but nothing on how to override the defaults. What i'm thinking now is to just manually call the action to set the language after it has been initialized, but would like to know if there is a better more direct way to do it already while initializing.

import {otherreducers} from "./Yourproject"

import {i18nState} from "redux-i18n"
// with Immutable.js:
import {i18nState} from "redux-i18n/immutable"

const appReducer = combineReducers({
  otherreducers,
  i18nState //here I would like to somehow pass the default lang value, if possible
})
metsawyr commented 5 years ago

@flynorc you should use 2nd argument of createStore function to initialize state. But this won't override lang. Lang should be passed in props anyway.