1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Fix null pointer exception in with-react-18next (#3944)

The example does not crash if a user chooses a non-existing language (e.g. goes to localhost:3000/?lng=ru)
This commit is contained in:
Alexander Kachkaev 2018-03-06 09:39:35 +00:00 committed by Tim Neutkens
parent 0107051eaa
commit a225da4bb1

View file

@ -45,7 +45,7 @@ i18n.getInitialProps = (req, namespaces) => {
req.i18n.languages.forEach((l) => { req.i18n.languages.forEach((l) => {
initialI18nStore[l] = {} initialI18nStore[l] = {}
namespaces.forEach((ns) => { namespaces.forEach((ns) => {
initialI18nStore[l][ns] = req.i18n.services.resourceStore.data[l][ns] || {} initialI18nStore[l][ns] = (req.i18n.services.resourceStore.data[l] || {})[ns] || {}
}) })
}) })