diff --git a/src/contexts/MatrixClientContext.tsx b/src/contexts/MatrixClientContext.tsx index 4c02f066b6..da351b1574 100644 --- a/src/contexts/MatrixClientContext.tsx +++ b/src/contexts/MatrixClientContext.tsx @@ -25,7 +25,10 @@ import React, { } from "react"; import { MatrixClient } from "matrix-js-sdk/src/client"; -const MatrixClientContext = createContext(undefined); +// This context is available to components under LoggedInView, +// the context must not be used by components outside a MatrixClientContext tree. +// This assertion allows us to make the type not nullable. +const MatrixClientContext = createContext(null as any); MatrixClientContext.displayName = "MatrixClientContext"; export default MatrixClientContext; diff --git a/src/contexts/SDKContext.ts b/src/contexts/SDKContext.ts index 82b47d09c4..bb10d0df72 100644 --- a/src/contexts/SDKContext.ts +++ b/src/contexts/SDKContext.ts @@ -38,7 +38,10 @@ import { VoiceBroadcastRecordingsStore, } from "../voice-broadcast"; -export const SDKContext = createContext(undefined); +// This context is available to components under MatrixChat, +// the context must not be used by components outside a SdkContextClass tree. +// This assertion allows us to make the type not nullable. +export const SDKContext = createContext(null as any); SDKContext.displayName = "SDKContext"; /**