Uncaught TypeError: mergedOptions.onMissingTranslation is not a function
See original GitHub issueI’m not sure if this is a bug or a feature, as its kind of jumping outside of the bounds of the documentation.
I currently have a boot-server file where I follow Option 2 from this thread using the exposed action creators, as I inject the localisations once off during server render. (this was how I injected the localisations in the prior version)
export default createServerRenderer((params) => {
return new Promise<RenderResult>((resolve, reject) => {
// Prepare Redux store with in-memory history,
const store = configureStore(createMemoryHistory());
const { translations } = params.data;
const onMissingTranslation = ({ translationId, languageCode }) => {
console.log(`Missing translationId: ${ translationId } for language: ${ languageCode }`);
return `Label Not Set`;
};
// get translation files
store.dispatch(initialize({
languages: [{ name: 'English', code: 'en' }],
translation: translations,
options: {
onMissingTranslation,
renderInnerHtml: true,
renderToStaticMarkup,
defaultLanguage: 'en',
}
}));
store.dispatch(addTranslationForLanguage(translations, 'en'));
store.dispatch(setActiveLanguage('en'));
// some code
const app = (
<LocalizeProvider store={store}>
<Provider store={store}>
<StaticRouter context={routerContext} location={params.location.path}
children={routes(instanceType, appRoutes)}/>
</Provider>
</LocalizeProvider>
);
// etc...
});
});
It works for the most part. That being said… since swapping over, and using the technique above. I have not been able to get the onMissingTranslations to actually work (javascript just explodes if there is no translation for a key) keep getting this error ‘Uncaught TypeError: mergedOptions.onMissingTranslation is not a function’ even with the above set.
Even when not setting the onMissingTranslation, I get the same issue… thus leading me to believe my setup or boot code might be somewhat wonky.
Versions: “react”: “16.2.0”, “react-redux”: “5.0.6”, “react-localize-redux”: “3.1.1”,
Side note… I’m not able to upgrade react version yet, as they’re aiming to remove some hooks that I depend on for SSR purposes… so I’m giving it some time until they stabilise.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (2 by maintainers)
@ryandrewjohnson whoa… I seem to have disappeared in the void… we had some flu going round at the office… let me take a stab at that and let you know whats up. sorry for the delay in my response. thanks for the snippet
@ryandrewjohnson I’ll be happy to help you. I’m just not sure what exactly you mean by editing the
LocalizeProvider
code. I have a react-localize-redux package in node_modules. What file exactly should I modify? lib/LocalizeProvider.js?