Sreeni
Sreeni
SSolidJS
Created by Sreeni on 7/19/2023 in #support
Transition state getting lost after an await inside ResourceFetcher
https://playground.solidjs.com/anonymous/c2f53a7d-9e76-4711-8e81-aa6bc2de12c6 Check the above link to see it in action Say if we have the following signal
const [show, setShow] = createSignal(false);
const [show, setShow] = createSignal(false);
And if we call setShow(true) within startTransition
startTransition(() => setShow(true));
startTransition(() => setShow(true));
And somewhere inside ResourceFetcher the value of show() is different above & below an await point as shown below
console.log('show=', show()); // true
await new Promise((r) => setTimeout(r, 1));
console.log('show=', show()); // false !!!
console.log('show=', show()); // true
await new Promise((r) => setTimeout(r, 1));
console.log('show=', show()); // false !!!
9 replies
SSolidJS
Created by Sreeni on 7/19/2023 in #support
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];
}
export default function useTransition() {
const [pending, setPending] = createSignal(false);
async function start(fn: () => unknown) {
setPending(true);
await startTransition(() => {
fn();
});
setPending(false);
}
return [pending, start];
}
1 replies