SolidJSS
SolidJSโ€ข3y ago
Sreeni

Issue with multiple useTransition

https://playground.solidjs.com/anonymous/ad274a3f-5cd0-4fa2-a852-c64bde3cdb77

Use the above playground link to see it in action. When clicking either one of the buttons, both show loading... Is this an expected behavior?

A workaround is to use the below useTransition instead

export default function useTransition() {
  const [pending, setPending] = createSignal(false);
  async function start(fn: () => unknown) {
    setPending(true);
    await startTransition(() => {
      fn();  
    });
    setPending(false);
  }
  return [pending, start];
}
Quickly discover what the solid compiler will generate from your JSX template
Was this page helpful?