ryandrewjohnson / react-localize-redux

Dead simple localization for your React components
https://ryandrewjohnson.github.io/react-localize-redux-docs/
MIT License
374 stars 88 forks source link

[Bug] onMissingTranslation is a non-serializable value #202

Closed tinuts closed 4 years ago

tinuts commented 4 years ago

Hi, after moving to redux-toolkit in order to reduce some boilerplate, I'm getting this error during the init of react-localize:

A non-serializable value was detected in an action, in the path: `payload.options.onMissingTranslation`. Value: () => '' 
Take a look at the logic that dispatched this action:  {type: "@@localize/INITIALIZE", payload: {…}}
[...]
(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)

Here is my options values:

store.dispatch(initialize({
  languages,
  translation: strings.french,
  options: {
    renderToStaticMarkup: false,
    renderInnerHtml: true,
    defaultLanguage: 'fr',
    onMissingTranslation: () => ''
  }
}));

Any idea if I can get rid of that error ? I'm not able to attribute false to onMissingTranslation, this produce an error.

Thanks for help, and your work !

maxbethke commented 1 year ago

Hi @tinuts, have you resolved the error? If so, how did you do it? I am facing the same problem right now.