SolidJSS
SolidJS3y ago
2 replies
alrightsure

useRouteData empty on HMR

I'm just curious about the expected behavior of useRouteData in Solid Start. It seems to return an empty response after HMR, but only in certain situations. I created two identical pages with different route data functions. One pulls from the Pokemon API and another accesses my firestore instance:

export const routeData = () => {
    return createServerData$(async () => {
        const resp = await fetch("https://pokeapi.co/api/v2/pokemon/ditto");
        return await resp.json();
    });
};


export const routeData = () => {
    return createServerData$(async () => {
        const exercisesSnapshot = await db.exercises.get();
        return exercisesSnapshot.docs.map(doc => ({ id: doc.id, ...doc.data() }));
    });
};


The Pokemon page seems to persist data through HMRs, however, my route data from firestore seems to be empty after an HMR. Does anyone have any insight into this?
Was this page helpful?