#Error when setting context

19 messages · Page 1 of 1 (latest)

sand aspen
#

Hi, I am getting the error "element must be connected to the dom" when setting context. Everything works fine if you load the page, unless you load another page first then navigate to the page from a link. Then setting the context value of the context throws the error.

gritty kestrel
#

I ran into this a few times, but I couldn't make a minimal reproduction. Can you try reproducing this somewhere? Either in the playground or a stackblitz or a simple repo?

marsh venture
#

I get this error in dynamic route

gritty kestrel
#

Yes I think that's where it is most likely to happen but maybe also in other cases where rendering is dynamic like using Resource.

marsh venture
#

yeah, I am doing a fetch in useClientEffect$

gritty kestrel
#

Interesting, I wonder if this is an issue with the element where the effect is run going away then? You could try adding a cleanup function to the effect which only console log and see if the error pops up after the console output.

marsh venture
#

I just had to us the <a> instead of Link, tho causes the page to reload

gritty kestrel
#

Sure that would work, but not really pinpointing the issue 😅

sand aspen
#

Hi, bit of an update, I don't have a reproduction but the issue for me was happening when the context was created in root.tsx and the update to the state was happening in a nested layout.

#

The behaviour was super inconsistent too, with it working for signals but not stores sometimes but the other way around worked other times.

#

I was not using a dynamic route.

#

The update was created during a client effect I believe.

marsh venture
#

Hi guys... using <a> in production, makes all pages stuck at the index page. those with <Link> work ok, just that when navigating to some pages with context I get this error "element must be connected to the dom"

gritty kestrel
#

That's just weird. How would a normal A link be stuck?

marsh venture
#

Update, in dev mode, I get the error. In preview and build mode the issues don't come up, and I navigate ok.

#

But this is bad to say the least and it is had to debug or reproduce

sand aspen
#

Do you or @gritty kestrel have a reproduction, I can try get around to making one when I'm back in the office next week but it seems quite difficult to do.