IvanLisz
IvanLisz
SSolidJS
Created by IvanLisz on 8/2/2023 in #support
Preserving State during HMR Errors
"solid-js": "^1.7.8", "solid-start": "^0.2.30", "solid-start-netlify": "^0.2.30",
4 replies
SSolidJS
Created by IvanLisz on 8/2/2023 in #support
Preserving State during HMR Errors
This works for providers but I think I would need to do it manually for each, and it won't work for components. let preservedInstance: any; export function InstanceProvider(props: any) { const [instance, setInstance] = createSignal(preservedInstance); onMount(async () => { if(instance()) { console.log("Instance restored", instance()) return; } console.log("Starting new Instance"); const newInstance = await start(); preservedInstance = newInstance; setInstance(newInstance); }); return <InstanceContext.Provider value={instance}>{props.children}</InstanceContext.Provider>; }
4 replies
SSolidJS
Created by IvanLisz on 8/2/2023 in #support
Preserving State during HMR Errors
I've tried https://github.com/solidjs/solid-refresh#refresh-granular without success, tho I might be missing something? would this be the correct approach?
4 replies