Footer
Hi everyone.
I'm trying to create my footer using a context that I have for SEO and retrive my social networks from Sanity CMS, but I'm facing the error on the image
The component code is on the thread.
Can anyone help me?
34 Replies
On
app.tsx
:
This is my SEO context
which index.tsx is the error referring?
Is the
footer/index.tsx
does commenting the show block fix it? just to narrow down the issue
if yes try commenting just the For block after that to try and narrow it down more
If I remove the
Show
apparently works
For example If I put console.log(value.slogan)
, the console shows me undefined
and on the browser shows me the correct value
I'm doing something wrong?
thats why I put the Show
on that partI think we are talking about different shows
are you talking about seo.slogan show?
I was talking about socialNetworks one
Yeah, sorry
for the social networks I remove it, but, for works, I need to remove the show on the
seo.slogan
but If remove that, the footer works but the slogan isn't displayedKeep having this
and if I click on the
index.tsx
so if I understand correctly if the slogan show is removed the error goes away?
goes to that part
Yes, but the slogan isn't displayed :/
Basically I did this:
and works, but not slogan :/
try removing keyed, seems like you don't need a keyed show
Without the keyed
try adding this createEffect(() => console.log(seo)) to see what are the value diff bw server and client
On the browser ⤴️
On console ⤴️
what about the object itself
⬆️ on the
useSeo
should I return the Accessor
instead of the value?
Let me seecannot say without seeing the useSeo implementation
oh it's there nvm
⬆️ From the
createEffect
⬆️ Without createEffect
on console
yes I think you should return context and not context()
This is my fetching data to sanity cms
I think solves
solved?
try returning an empty object in the catch, maybe that helps
No 😦
I try again and already back, if remove the
show
on the slogan works but don't show the slogan, if add it again, i have the same error
I'm out of ideas to be honest 😦
Apparently, if I remove the createMemo
on the contexts seems works
but let me try to restart the server again to check
But without the createMemo
seems that I have a refresh on the ui
Thank you for your time and sorry for be a noob, but I'm totally lost at this point 🥲
Could be because of the createMemo
? :/
The only way that fix it is fetching the data again on the footer instead of using the context, so for now I will follow with that approachtry putting a
Suspense
around your whole root or even around the whole router, consuming seoSettings
inside the createMemo
is causing SeoContextProvider
to suspend outside of the Suspense
you already have
using a plain function rather than memo should also work since that moves the evaluation of setSettings
from the memo to the place that invokes the functionSo instead of have the
Suspense
for the children, wrap my entire root
content in Suspense
Thanks I will try that 🙏
Again, sorry for the noob mistakes/questionsyeah that should work
though it's fine to have multiple suspenses, one for the whole root and one for the routes
also i'd recommend to not call
context()
inside useSeo
as it will no longer be reactive
unless you're calling useSeo
directly inside JSX or an effectOk
one question
for examplo I'm fetching the blog posts, shouldn't use a suspense for the list of posts because already have a global suspense?
That depends on how you want the list of posts to behave during navigations
If during navigation to the list you want to block navigation until the list is done, then just rely on the global suspense
If you want the navigation to occur straight away and show a fallback while the posts load, then add a dedicated Suspense
You can add and omit Suspense in different parts of your app to control how things should load
but If I put the second
suspense
, the global will be ignored?The global one will still handle
SeoContextProvider
suspending, it just won't handle everything below the second Suspense
(assuming you haven't changed SeoContextProvider
to not suspend anymore)
Otherwise yeah it won't really do anythingThanks @Brendonovich
Seems that works, I'm already using the context on the footer and change the
useSeo
to return the acessor
instead of the value