IvanLisz
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
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