SolidJSS
SolidJSโ€ข3y agoโ€ข
3 replies
IvanLisz

Preserving State during HMR Errors

I'm using multiple providers like:
export function InstanceProvider(props: any) { const [instance, setInstance] = createSignal(); onMount(async () => { const newInstance = await start(); setInstance(newInstance); }); return <InstanceContext.Provider value={instance}>{props.children}</InstanceContext.Provider>; }



HMR works well, but when I get an unrelated error on some other component like
Cannot read properties of undefined (reading 'charAt')
and click "Clear errors and retry", the InstanceProvider state is lost.


Is there a recommended way to preserve state and avoid remounts of specific components?
Was this page helpful?