chore: upgrade React 18→19 and fix breaking type changes

- react 18.2.0 to 19.2.6
- react-dom 18.2.0 to 19.2.6
- @types/react 18.2.39 to 19.2.15
- @types/react-dom 18.2.17 to 19.2.3

React 19 breaking changes fixed:
- useRef<T>(null) now returns RefObject<T | null>; cast to
  RefObject<T> at 16 component call sites (safe, runtime unchanged)
- useRef<T>() without arg no longer valid; add | undefined>(undefined)
  in useDebounce, useFileDrop, useThrottle, useVirtualPaginator hooks,
  RoomInput, RoomTimeline, and ClientNonUIFeatures
- useReducer<typeof reducer> 1-arg form removed; drop explicit type arg
  in useForceUpdate (inferred from reducer function)
- global JSX namespace removed; import type { JSX } from react in
  react-custom-html-parser.tsx

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lotus Bot
2026-05-22 13:24:07 -04:00
parent d6ae29f8f3
commit 7079462503
28 changed files with 89 additions and 98 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ export function useDebounce<T extends unknown[]>(
callback: DebounceCallback<T>,
options?: DebounceOptions,
): DebounceCallback<T> {
const timeoutIdRef = useRef<number>();
const timeoutIdRef = useRef<number | undefined>(undefined);
const { wait, immediate } = options ?? {};
const debounceCallback = useCallback(
+1 -1
View File
@@ -14,7 +14,7 @@ export const useFileDropZone = (
zoneRef: RefObject<HTMLElement>,
onDrop: (file: File[]) => void,
): boolean => {
const dragStateRef = useRef<'start' | 'leave' | 'over'>();
const dragStateRef = useRef<'start' | 'leave' | 'over' | undefined>(undefined);
const [active, setActive] = useState(false);
useEffect(() => {
+1 -1
View File
@@ -3,7 +3,7 @@ import { useReducer } from 'react';
const reducer = (prevCount: number): number => prevCount + 1;
export const useForceUpdate = (): [number, () => void] => {
const [state, dispatch] = useReducer<typeof reducer>(reducer, 0);
const [state, dispatch] = useReducer(reducer, 0);
return [state, dispatch];
};
+2 -2
View File
@@ -11,8 +11,8 @@ export function useThrottle<T extends unknown[]>(
callback: ThrottleCallback<T>,
options?: ThrottleOptions,
): ThrottleCallback<T> {
const timeoutIdRef = useRef<number>();
const argsRef = useRef<T>();
const timeoutIdRef = useRef<number | undefined>(undefined);
const argsRef = useRef<T | undefined>(undefined);
const { wait, immediate } = options ?? {};
const debounceCallback = useCallback(
+15 -9
View File
@@ -166,16 +166,22 @@ export const useVirtualPaginator = <TScrollElement extends HTMLElement>(
const initialRenderRef = useRef(true);
const restoreScrollRef = useRef<{
scrollTop: number;
anchorOffsetTop: number;
anchorItem: number;
}>();
const restoreScrollRef = useRef<
| {
scrollTop: number;
anchorOffsetTop: number;
anchorItem: number;
}
| undefined
>(undefined);
const scrollToItemRef = useRef<{
index: number;
opts?: ScrollToOptions;
}>();
const scrollToItemRef = useRef<
| {
index: number;
opts?: ScrollToOptions;
}
| undefined
>(undefined);
const propRef = useRef({
range,