SolidJSS
SolidJSโ€ข3y agoโ€ข
4 replies
Bersaelor

Suspense doesn't seem to work with ContextProvider

hey, so recently I noticed,
If I use createResource(fetch) and then put <Suspense fallback={<Placeholder>}> I will see the placeholder during loading.
But if I have createResource(fetch) inside a ContextProvider, i.e.:

const ContextProvider: ParentComponent = (props) => {
  const [data] = createResource(isAuthenticated, fetch);

return (
    <Context.Provider value={{
        data
      }}>
       {props.children}
    </Context.Provider>
}

and then have a
const SomeChild = () => {
  const { data } = useAppState();

<Suspense fallback={<Placeholder>}>
  {data()}
<Suspense>
}

then I will not see the suspense-placeholder and in fact my UI will not update until the data is loaded.
Does suspense & createResource not work around context-provide and use?
Was this page helpful?