mirror of
https://github.com/vector-im/element-call.git
synced 2026-03-28 06:50:26 +00:00
Modernize how we use React contexts (#3359)
* Replace useContext with use The docs recommend the use hook because it is simpler and allows itself to be called conditionally. * Simplify our context providers React 19 lets you omit the '.Provider' bit.
This commit is contained in:
@@ -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 (
|
||||
<ReactionsSenderContext.Provider
|
||||
<ReactionsSenderContext
|
||||
value={{
|
||||
supportsReactions,
|
||||
toggleRaisedHand,
|
||||
@@ -165,6 +165,6 @@ export const ReactionsSenderProvider = ({
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</ReactionsSenderContext.Provider>
|
||||
</ReactionsSenderContext>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user