Closed AprilNEA closed 1 year ago
Is the computational overhead here worth using useMemo
like this?
const clear = useCallback(() => {
clearTimeout(timerIdRef.current);
timerIdRef.current = undefined;
}, []);
const retimerWithClear = useMemo(() => {
const retimerFn = retimer as RetimerType;
retimerFn.clear = clear;
return retimerFn;
}, [retimer, clear]);
return retimerWithClear
Well, finally found what the problem is. ðŸ˜
This will work well at certain times, such as a search box(swr) with debounced input is submitted by the user.
I'm not sure this is correct or a best practice.