Type fixes for react v19 compatibility (#2937)

This commit is contained in:
Hugh Nimmo-Smith
2025-01-13 14:54:42 +00:00
committed by GitHub
parent c8b30dd8a7
commit 2f5f0978ad
17 changed files with 33 additions and 14 deletions

View File

@@ -23,9 +23,9 @@ export const useReactiveState = <T>(
updateFn: (prevState?: T) => T,
deps: DependencyList,
): [T, Dispatch<SetStateAction<T>>] => {
const state = useRef<T>();
const state = useRef<T | undefined>(undefined);
if (state.current === undefined) state.current = updateFn();
const prevDeps = useRef<DependencyList>();
const prevDeps = useRef<DependencyList | undefined>(undefined);
// Since we store the state in a ref, we use this counter to force an update
// when someone calls setState