Next.js Discord

Discord Forum

Help with Context

Unanswered
Cão de Castro Laboreiro posted this in #help-forum
Open in Discord
Cão de Castro LaboreiroOP
Hi guys, I have this context set up. The data console logs as json, so it's being fetched properly. However when I import the context into the root layout the data is undefined. Can someone please provide some clarification. Thanks in advance!

6 Replies

why do you pass "value={DataContextProvider.data}"?
@Eric Burel why do you pass "value={DataContextProvider.data}"?
Cão de Castro LaboreiroOP
that's a mistake, sorry I got rid of that line
I was just trying random things lol
but yeah, still the data comes up undefined, any clues??
Maybe the context is too outside ? Can you put it back in the body? But that looks weird
Cão de Castro LaboreiroOP
yeah, that doesn't work. it's scoped correctly. it's weird I can't get data to console.log anywhere in the rootlayout