diff --git a/src/App.tsx b/src/App.tsx index cf403299..72def586 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -77,7 +77,7 @@ export const App: FC = ({ vm }) => { {loaded ? ( - + ( @@ -96,7 +96,7 @@ export const App: FC = ({ vm }) => { - + ) : ( diff --git a/src/ClientContext.tsx b/src/ClientContext.tsx index bde20dc8..1488965a 100644 --- a/src/ClientContext.tsx +++ b/src/ClientContext.tsx @@ -11,7 +11,7 @@ import { useEffect, useState, createContext, - useContext, + use, useRef, useMemo, type JSX, @@ -69,8 +69,7 @@ const ClientContext = createContext(undefined); export const ClientContextProvider = ClientContext.Provider; -export const useClientState = (): ClientState | undefined => - useContext(ClientContext); +export const useClientState = (): ClientState | undefined => use(ClientContext); export function useClient(): { client?: MatrixClient; @@ -350,9 +349,7 @@ export const ClientProvider: FC = ({ children }) => { return ; } - return ( - {children} - ); + return {children}; }; export type InitResult = { diff --git a/src/MediaDevicesContext.ts b/src/MediaDevicesContext.ts index 404815ba..cc3af742 100644 --- a/src/MediaDevicesContext.ts +++ b/src/MediaDevicesContext.ts @@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial Please see LICENSE in the repository root for full details. */ -import { createContext, useContext, useMemo } from "react"; +import { createContext, use, useMemo } from "react"; import { useObservableEagerState } from "observable-hooks"; import { type MediaDevices } from "./state/MediaDevices"; @@ -15,7 +15,7 @@ export const MediaDevicesContext = createContext( ); export function useMediaDevices(): MediaDevices { - const mediaDevices = useContext(MediaDevicesContext); + const mediaDevices = use(MediaDevicesContext); if (mediaDevices === undefined) throw new Error( "useMediaDevices must be used within a MediaDevices context provider", diff --git a/src/grid/Grid.tsx b/src/grid/Grid.tsx index 65525446..25577abd 100644 --- a/src/grid/Grid.tsx +++ b/src/grid/Grid.tsx @@ -24,7 +24,7 @@ import { createContext, forwardRef, memo, - useContext, + use, useEffect, useMemo, useRef, @@ -124,7 +124,7 @@ interface LayoutContext { const LayoutContext = createContext(null); function useLayoutContext(): LayoutContext { - const context = useContext(LayoutContext); + const context = use(LayoutContext); if (context === null) throw new Error("useUpdateLayout called outside a Grid layout context"); return context; @@ -532,14 +532,14 @@ export function Grid< className={classNames(className, styles.grid)} style={style} > - + - + {tileTransitions((spring, { id, model, onDrag, width, height }) => ( (undefined); export function useTrackProcessor(): ProcessorState { - const state = useContext(ProcessorContext); + const state = use(ProcessorContext); if (state === undefined) throw new Error( "useTrackProcessor must be used within a ProcessorProvider", @@ -83,9 +83,5 @@ export const ProcessorProvider: FC = ({ children }) => { [supported, blurActivated, blur], ); - return ( - - {children} - - ); + return {children}; }; diff --git a/src/reactions/useReactionsSender.tsx b/src/reactions/useReactionsSender.tsx index 85f1505c..30804d4b 100644 --- a/src/reactions/useReactionsSender.tsx +++ b/src/reactions/useReactionsSender.tsx @@ -8,7 +8,7 @@ Please see LICENSE in the repository root for full details. import { EventType, RelationType } from "matrix-js-sdk"; import { createContext, - useContext, + use, type ReactNode, useCallback, useMemo, @@ -34,7 +34,7 @@ const ReactionsSenderContext = createContext< >(undefined); export const useReactionsSender = (): ReactionsSenderContextType => { - const context = useContext(ReactionsSenderContext); + const context = use(ReactionsSenderContext); if (!context) { throw new Error("useReactions must be used within a ReactionsProvider"); } @@ -157,7 +157,7 @@ export const ReactionsSenderProvider = ({ ); return ( - {children} - + ); }; diff --git a/src/room/GroupCallView.test.tsx b/src/room/GroupCallView.test.tsx index a7c8de56..bf73c15d 100644 --- a/src/room/GroupCallView.test.tsx +++ b/src/room/GroupCallView.test.tsx @@ -149,7 +149,7 @@ function createGroupCallView( const { getByText } = render( - + - + , ); diff --git a/src/room/InCallView.test.tsx b/src/room/InCallView.test.tsx index d681a584..e5a789e7 100644 --- a/src/room/InCallView.test.tsx +++ b/src/room/InCallView.test.tsx @@ -149,13 +149,13 @@ function createInCallView(): RenderResult & { rtcSession.joined = true; const renderResult = render( - + - + - + - + , ); return { diff --git a/src/room/InCallView.tsx b/src/room/InCallView.tsx index b469e292..136db0b9 100644 --- a/src/room/InCallView.tsx +++ b/src/room/InCallView.tsx @@ -172,7 +172,7 @@ export const ActiveCall: FC = (props) => { if (livekitRoom === undefined || vm === null) return null; return ( - + = (props) => { connState={connState} /> - + ); }; diff --git a/src/room/MuteStates.test.tsx b/src/room/MuteStates.test.tsx index 9d4a63e7..13dc8ee0 100644 --- a/src/room/MuteStates.test.tsx +++ b/src/room/MuteStates.test.tsx @@ -124,14 +124,14 @@ describe("useMuteStates", () => { render( - - + , ); expect(screen.getByTestId("audio-enabled").textContent).toBe("false"); @@ -143,9 +143,9 @@ describe("useMuteStates", () => { render( - + - + , ); expect(screen.getByTestId("audio-enabled").textContent).toBe("true"); @@ -159,9 +159,9 @@ describe("useMuteStates", () => { render( - + - + , ); expect(screen.getByTestId("audio-enabled").textContent).toBe("false"); @@ -178,9 +178,9 @@ describe("useMuteStates", () => { render( - + - + , ); expect(screen.getByTestId("audio-enabled").textContent).toBe("false"); @@ -192,9 +192,9 @@ describe("useMuteStates", () => { render( - + - + , ); expect(screen.getByTestId("audio-enabled").textContent).toBe("false"); @@ -224,13 +224,13 @@ describe("useMuteStates", () => { return ( - + - + ); }; diff --git a/src/useAudioContext.test.tsx b/src/useAudioContext.test.tsx index 440a8881..12ebeb13 100644 --- a/src/useAudioContext.test.tsx +++ b/src/useAudioContext.test.tsx @@ -105,9 +105,9 @@ afterEach(() => { test("can play a single sound", async () => { const { findByText } = render( - + - , + , ); await user.click(await findByText("Valid sound")); expect(testAudioContext.createBufferSource).toHaveBeenCalledOnce(); @@ -115,9 +115,9 @@ test("can play a single sound", async () => { test("will ignore sounds that are not registered", async () => { const { findByText } = render( - + - , + , ); await user.click(await findByText("Invalid sound")); expect(testAudioContext.createBufferSource).not.toHaveBeenCalled(); @@ -125,7 +125,7 @@ test("will ignore sounds that are not registered", async () => { test("will use the correct device", () => { render( - ()), @@ -135,7 +135,7 @@ test("will use the correct device", () => { })} > - , + , ); expect(testAudioContext.createBufferSource).not.toHaveBeenCalled(); expect(testAudioContext.setSinkId).toHaveBeenCalledWith("chosen-device"); @@ -144,9 +144,9 @@ test("will use the correct device", () => { test("will use the correct volume level", async () => { soundEffectVolumeSetting.setValue(0.33); const { findByText } = render( - + - , + , ); await user.click(await findByText("Valid sound")); expect(testAudioContext.gain.gain.setValueAtTime).toHaveBeenCalledWith( @@ -158,7 +158,7 @@ test("will use the correct volume level", async () => { test("will use the pan if earpiece is selected", async () => { const { findByText } = render( - ()), @@ -168,7 +168,7 @@ test("will use the pan if earpiece is selected", async () => { })} > - , + , ); await user.click(await findByText("Valid sound")); expect(testAudioContext.pan.pan.setValueAtTime).toHaveBeenCalledWith(1, 0);