Fix settings toggles sometimes not being toggable

Co-authored-by: William Oldham <github@binaryoverload.co.uk>
This commit is contained in:
mrjvs 2023-12-21 21:00:36 +01:00
parent 690b1c6e68
commit 0e830ee0a6

View File

@ -24,7 +24,7 @@ export function useDerived<T>(
const setter = useCallback<Dispatch<SetStateAction<T>>>( const setter = useCallback<Dispatch<SetStateAction<T>>>(
(inp) => { (inp) => {
if (!(inp instanceof Function)) setOverwrite(inp); if (!(inp instanceof Function)) setOverwrite(inp);
else setOverwrite((s) => inp(s ?? initial)); else setOverwrite((s) => inp(s !== undefined ? s : initial));
}, },
[initial, setOverwrite] [initial, setOverwrite]
); );