Describe the bug
see: https://github.com/sadmann7/diceui/blob/main/docs/registry/bases/base/ui/masonry.tsx#L923
function onRafSchedule<T extends unknown[]>(
callback: (...args: T) => void,
): OnRafScheduleReturn<T> {
let lastArgs: T = [] as unknown as T;
let frameId: number | null = null;
function onCallback(...args: T) {
lastArgs = args;
if (frameId) // This function will never be executed. Is the correct way to write it if (!frameId)?
frameId = requestAnimationFrame(() => {
frameId = null;
callback(...lastArgs);
});
}
onCallback.cancel = () => {
if (!frameId) return;
cancelAnimationFrame(frameId);
frameId = null;
};
return onCallback;
}
How to reproduce
https://github.com/sadmann7/diceui/blob/main/docs/registry/bases/base/ui/masonry.tsx#L923
Link to reproduction
https://github.com/sadmann7/diceui/blob/main/docs/registry/bases/base/ui/masonry.tsx#L923
Additional information
No response
Describe the bug
see: https://github.com/sadmann7/diceui/blob/main/docs/registry/bases/base/ui/masonry.tsx#L923
How to reproduce
https://github.com/sadmann7/diceui/blob/main/docs/registry/bases/base/ui/masonry.tsx#L923
Link to reproduction
https://github.com/sadmann7/diceui/blob/main/docs/registry/bases/base/ui/masonry.tsx#L923
Additional information
No response