Reputation: 4625
I'm using redux-react-native-i18n
for Localization.
I'm getting this error
TypeError: undefined is not an object (evaluating '_ref$i18n.currentLanguage')
Here is my code in store/index.js
import { i18nReducer, i18nActions, Loc } from 'redux-react-native-i18n';
reducers.i18n = i18nReducer
const store = createStore(
reducers,
{},
compose(
applyMiddleware(thunk)
)
);
const dictionaries = {
'en-US': {
'oh': 'Order History',
},
'ko-KR': {
'oh': '주문내역',
},
//...
}
store.dispatch( i18nActions.setDictionaries( dictionaries ) )
Set Language (store.index.js - continue)
const languages = [
{
code: 'en-US',
name: 'english'
},
{
code: 'ko-KR',
name: 'Korean'
},
//...
]
store.dispatch( i18nActions.setLanguages( languages ) )
store.dispatch( i18nActions.setCurrentLanguage( 'en-US' ) ) <<<It's not working?
export default store;
Here I'm calling <Loc />
Text component which translate to the current language.
<H2 style={styles.locationTitle}><Loc locKey="oh"/></H2>
<- error here
I did console.log('hi')
in the store and it seems my store is working correctly. I'm running this on Android.
Upvotes: 1
Views: 332
Reputation: 452
Can you try to use combineReducers( reducers )
. Seems that your variable "reducers" is an object. But it must be a function - https://redux.js.org/api-reference/createstore
Upvotes: 1