createResource does not trigger suspense when its first-argument signal changes
I have a modal component, with its open state managed by a signal. I want to fetch the data that should be displayed in the modal only once the modal is opened by the user and display a loading message while data is still loading. However, Suspense is not triggered in my case, and I don't really understand why. Isn't it supposed to be triggered in this case?
4 Replies
You say it isn't triggered - what is the behavior you're seeing?
You're not seeing the fallback?
@foolswisdom Exactly, I'm not seeing the fallback. I'm logging
data()
in a createEffect, I'm seeing undefined
and when I open the modal, it switches to the data returned by the server after some delay, but suspense is not triggered/no loading fallback.fetcher
afaik. You should use an object like { open: boolean }
as the return value of the source
more likely than not the pattern in use by should might work; be careful not to somehow cause
Dialog
and DialogContent
means that the read is not executing under suspense
the solution depends on the implementation but reading and discarding data
anywhere inside suspense but outside DialogContent
DialogContent
to rerun though
eta: ideally suspense should be within DialogContent
but it doesn't seem like that's possible here