Type fixes for react v19 compatibility (#2937)
This commit is contained in:
@@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
Please see LICENSE in the repository root for full details.
|
Please see LICENSE in the repository root for full details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { type FC, Suspense, useEffect, useState } from "react";
|
import { type FC, type JSX, Suspense, useEffect, useState } from "react";
|
||||||
import { BrowserRouter, Route, useLocation, Routes } from "react-router-dom";
|
import { BrowserRouter, Route, useLocation, Routes } from "react-router-dom";
|
||||||
import * as Sentry from "@sentry/react";
|
import * as Sentry from "@sentry/react";
|
||||||
import { TooltipProvider } from "@vector-im/compound-web";
|
import { TooltipProvider } from "@vector-im/compound-web";
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
useContext,
|
useContext,
|
||||||
useRef,
|
useRef,
|
||||||
useMemo,
|
useMemo,
|
||||||
|
type JSX,
|
||||||
} from "react";
|
} from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { logger } from "matrix-js-sdk/src/logger";
|
import { logger } from "matrix-js-sdk/src/logger";
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export const useInteractiveRegistration = (
|
|||||||
undefined,
|
undefined,
|
||||||
);
|
);
|
||||||
|
|
||||||
const authClient = useRef<MatrixClient>();
|
const authClient = useRef<MatrixClient | undefined>(undefined);
|
||||||
if (!authClient.current) {
|
if (!authClient.current) {
|
||||||
authClient.current = createClient({
|
authClient.current = createClient({
|
||||||
baseUrl: Config.defaultHomeserverUrl()!,
|
baseUrl: Config.defaultHomeserverUrl()!,
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export function useRecaptcha(sitekey?: string): {
|
|||||||
} {
|
} {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [recaptchaId] = useState(() => randomString(16));
|
const [recaptchaId] = useState(() => randomString(16));
|
||||||
const promiseRef = useRef<RecaptchaPromiseRef>();
|
const promiseRef = useRef<RecaptchaPromiseRef | undefined>(undefined);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!sitekey) return;
|
if (!sitekey) return;
|
||||||
|
|||||||
@@ -5,7 +5,13 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
Please see LICENSE in the repository root for full details.
|
Please see LICENSE in the repository root for full details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { type ComponentType, memo, type RefObject, useRef } from "react";
|
import {
|
||||||
|
type ComponentType,
|
||||||
|
type JSX,
|
||||||
|
memo,
|
||||||
|
type RefObject,
|
||||||
|
useRef,
|
||||||
|
} from "react";
|
||||||
import { type EventTypes, type Handler, useDrag } from "@use-gesture/react";
|
import { type EventTypes, type Handler, useDrag } from "@use-gesture/react";
|
||||||
import { type SpringValue } from "@react-spring/web";
|
import { type SpringValue } from "@react-spring/web";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
forwardRef,
|
forwardRef,
|
||||||
type ReactNode,
|
type ReactNode,
|
||||||
useId,
|
useId,
|
||||||
|
type JSX,
|
||||||
} from "react";
|
} from "react";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ Copyright 2023, 2024 New Vector Ltd.
|
|||||||
SPDX-License-Identifier: AGPL-3.0-only
|
SPDX-License-Identifier: AGPL-3.0-only
|
||||||
Please see LICENSE in the repository root for full details.
|
Please see LICENSE in the repository root for full details.
|
||||||
*/
|
*/
|
||||||
import { useState } from "react";
|
import { useState, type JSX } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
import styles from "./StarRatingInput.module.css";
|
import styles from "./StarRatingInput.module.css";
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
useMemo,
|
useMemo,
|
||||||
useRef,
|
useRef,
|
||||||
useState,
|
useState,
|
||||||
|
type JSX,
|
||||||
} from "react";
|
} from "react";
|
||||||
import { createMediaDeviceObserver } from "@livekit/components-core";
|
import { createMediaDeviceObserver } from "@livekit/components-core";
|
||||||
import { map, startWith } from "rxjs";
|
import { map, startWith } from "rxjs";
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
type ReactNode,
|
type ReactNode,
|
||||||
useCallback,
|
useCallback,
|
||||||
useMemo,
|
useMemo,
|
||||||
|
type JSX,
|
||||||
} from "react";
|
} from "react";
|
||||||
import { type MatrixRTCSession } from "matrix-js-sdk/src/matrixrtc/MatrixRTCSession";
|
import { type MatrixRTCSession } from "matrix-js-sdk/src/matrixrtc/MatrixRTCSession";
|
||||||
import { logger } from "matrix-js-sdk/src/logger";
|
import { logger } from "matrix-js-sdk/src/logger";
|
||||||
|
|||||||
@@ -154,11 +154,11 @@ export const GroupCallView: FC<Props> = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const deviceContext = useMediaDevices();
|
const deviceContext = useMediaDevices();
|
||||||
const latestDevices = useRef<MediaDevices>();
|
const latestDevices = useRef<MediaDevices | undefined>(undefined);
|
||||||
latestDevices.current = deviceContext;
|
latestDevices.current = deviceContext;
|
||||||
|
|
||||||
// TODO: why do we use a ref here instead of using muteStates directly?
|
// TODO: why do we use a ref here instead of using muteStates directly?
|
||||||
const latestMuteStates = useRef<MuteStates>();
|
const latestMuteStates = useRef<MuteStates | undefined>(undefined);
|
||||||
latestMuteStates.current = muteStates;
|
latestMuteStates.current = muteStates;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import {
|
|||||||
useMemo,
|
useMemo,
|
||||||
useRef,
|
useRef,
|
||||||
useState,
|
useState,
|
||||||
|
type JSX,
|
||||||
} from "react";
|
} from "react";
|
||||||
import useMeasure from "react-use-measure";
|
import useMeasure from "react-use-measure";
|
||||||
import { type MatrixRTCSession } from "matrix-js-sdk/src/matrixrtc/MatrixRTCSession";
|
import { type MatrixRTCSession } from "matrix-js-sdk/src/matrixrtc/MatrixRTCSession";
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
Please see LICENSE in the repository root for full details.
|
Please see LICENSE in the repository root for full details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { type FC, useCallback, useMemo, useState } from "react";
|
import { type FC, useCallback, useMemo, useState, type JSX } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { type MatrixClient } from "matrix-js-sdk/src/matrix";
|
import { type MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||||
import { Button } from "@vector-im/compound-web";
|
import { Button } from "@vector-im/compound-web";
|
||||||
|
|||||||
@@ -5,7 +5,14 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
Please see LICENSE in the repository root for full details.
|
Please see LICENSE in the repository root for full details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { type FC, useEffect, useState, type ReactNode, useRef } from "react";
|
import {
|
||||||
|
type FC,
|
||||||
|
useEffect,
|
||||||
|
useState,
|
||||||
|
type ReactNode,
|
||||||
|
useRef,
|
||||||
|
type JSX,
|
||||||
|
} from "react";
|
||||||
import { logger } from "matrix-js-sdk/src/logger";
|
import { logger } from "matrix-js-sdk/src/logger";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { CheckIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
|
import { CheckIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ export const useLoadGroupCall = (
|
|||||||
viaServers: string[],
|
viaServers: string[],
|
||||||
): GroupCallStatus => {
|
): GroupCallStatus => {
|
||||||
const [state, setState] = useState<GroupCallStatus>({ kind: "loading" });
|
const [state, setState] = useState<GroupCallStatus>({ kind: "loading" });
|
||||||
const activeRoom = useRef<Room>();
|
const activeRoom = useRef<Room | undefined>(undefined);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const bannedError = useCallback(
|
const bannedError = useCallback(
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ Please see LICENSE in the repository root for full details.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { type FC, useCallback } from "react";
|
import { type FC, useCallback, type JSX } from "react";
|
||||||
import { Button } from "@vector-im/compound-web";
|
import { Button } from "@vector-im/compound-web";
|
||||||
import { logger } from "matrix-js-sdk/src/logger";
|
import { logger } from "matrix-js-sdk/src/logger";
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ import { useRef } from "react";
|
|||||||
* React hook that returns the value given on the initial render.
|
* React hook that returns the value given on the initial render.
|
||||||
*/
|
*/
|
||||||
export function useInitial<T>(getValue: () => T): T {
|
export function useInitial<T>(getValue: () => T): T {
|
||||||
const ref = useRef<{ value: T }>();
|
const ref = useRef<{ value: T }>(undefined);
|
||||||
|
// only evaluate `getValue` if the ref is undefined
|
||||||
ref.current ??= { value: getValue() };
|
ref.current ??= { value: getValue() };
|
||||||
return ref.current.value;
|
return ref.current.value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ export const useReactiveState = <T>(
|
|||||||
updateFn: (prevState?: T) => T,
|
updateFn: (prevState?: T) => T,
|
||||||
deps: DependencyList,
|
deps: DependencyList,
|
||||||
): [T, Dispatch<SetStateAction<T>>] => {
|
): [T, Dispatch<SetStateAction<T>>] => {
|
||||||
const state = useRef<T>();
|
const state = useRef<T | undefined>(undefined);
|
||||||
if (state.current === undefined) state.current = updateFn();
|
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
|
// Since we store the state in a ref, we use this counter to force an update
|
||||||
// when someone calls setState
|
// when someone calls setState
|
||||||
|
|||||||
Reference in New Issue
Block a user