Cannot read properties of null even though I check
Unanswered
Sun bear posted this in #help-forum
Sun bearOP
In a page.tsx I have some code somewhat like this:
I check if !user, so why do I get an error like this:
if (!user) {
notFound();
}
// Do something with user
console.log(user.partner_id);I check if !user, so why do I get an error like this:
Cannot read properties of null (reading 'field')9 Replies
Sun bearOP
well its saying cannot read property of null, meaning user is null
Also im 100% sure it exists
you tried console.log(user)
Sun bearOP
no because i dont see this that often, every now and then and no particular user i can tell. Its also only in prd that i have this issue
Are you sure your .env is right?
try running
npm run build locally and npm start and see@Sun bear is your issue resolved
If you're facing any other issue(which could be a different post), don't hesitate to ping and let me know!