Cannot destructure property `components` of 'undefined' or 'null'.
See original GitHub issueI completed my project by using next-i18next. The project is working fine on local server. After I deployed the project to the server, firebase function console is giving me this error.
TypeError: Cannot destructure property
components of 'undefined' or 'null'. at Server.renderToHTMLWithComponents (/srv/node_modules/next/dist/next-server/server/next-server.js:560:37) at Server.renderErrorToHTML (/srv/node_modules/next/dist/next-server/server/next-server.js:821:35) at <anonymous>
If I remove the codeline “appwithtranslation” from _app.js the page is loading without translation on the server.
import React from 'react'
import App from 'next/app'
import { appWithTranslation } from '../i18n'
class MyApp extends App {
render() {
const { Component, pageProps } = this.props
console.log("_appp",this.props)
return (
<Component {...pageProps} />
)
}
}
export default appWithTranslation(MyApp)
i18n.js
const NextI18Next = require('next-i18next').default
module.exports = new NextI18Next({
defaultLanguage: 'en',
otherLanguages: ['tr',"ar","ru"],
localeSubpaths: {
ar: "ar",
en: 'en',
tr: 'tr',
ru:"ru"
}
})
server.js
`const express = require('express')
const next = require('next')
const nextI18NextMiddleware = require('next-i18next/middleware').default
const nextI18next = require('./i18n')
const port = process.env.PORT || 3000
const app = next({ dev: process.env.NODE_ENV !== 'production' })
const handle = app.getRequestHandler();
(async () => {
await app.prepare()
const server = express()
await nextI18next.initPromise
server.use(nextI18NextMiddleware(nextI18next))
server.get('*', (req, res) => handle(req, res))
await server.listen(port)
console.log(`> Ready on http://localhost:${port}`) // eslint-disable-line no-console
})()`
Is there any solution that I can fix this problem?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:13 (3 by maintainers)
Top Results From Across the Web
Cannot destructure property `components` of 'undefined' or 'null'.
The project is working fine on local server. After I deployed the project to the server, firebase function console is giving me this...
Read more >Cannot destructure property of null - Stack Overflow
When the component tries to mount, it throws an error that it can't destructure user from auth because auth is null at that...
Read more >Cannot destructure Property of Null Error in JavaScript
The "Cannot destructure property of null" error occurs when we try to destructure a property from a value that is equal to null...
Read more >Next.js error: Cannot destructure property? : r/learnjavascript
I have tried removing the brackets which then leads to an error telling me that loginUser is undefined.
Read more >[Solved]-Vuejs Cannot destructure property-Vue.js
Because you're destructing the second parameter which is undefined, remove the _ which is defined as first parameter: async signUp({ username, password, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi, in my case I just had to add this
COPY --from=builder /app/public/ ./public
It seems to occur only when
defaultLanguage
does not have a matching locale dir with its common.json inside it. The error seems to only occur in production.So let’s say
defaultLanguage
is set tode
, the error is thrown when you forget to createpublic/static/locales/de/common.json
.