From 4c8fd006f6a994783a43e4744a3167db7aefc159 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Tue, 6 May 2025 22:50:28 +0300 Subject: New Edit Profile dialog on web, use new Edit Image dialog everywhere (#8220) --- src/components/Dialog/context.ts | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/components/Dialog/context.ts') diff --git a/src/components/Dialog/context.ts b/src/components/Dialog/context.ts index eb892403f..2ecf5ba61 100644 --- a/src/components/Dialog/context.ts +++ b/src/components/Dialog/context.ts @@ -1,4 +1,11 @@ -import React from 'react' +import { + createContext, + useContext, + useEffect, + useId, + useMemo, + useRef, +} from 'react' import {useDialogStateContext} from '#/state/dialogs' import { @@ -8,7 +15,7 @@ import { } from '#/components/Dialog/types' import {BottomSheetSnapPoint} from '../../../modules/bottom-sheet/src/BottomSheet.types' -export const Context = React.createContext({ +export const Context = createContext({ close: () => {}, isNativeDialog: false, nativeSnapPoint: BottomSheetSnapPoint.Hidden, @@ -18,18 +25,18 @@ export const Context = React.createContext({ }) export function useDialogContext() { - return React.useContext(Context) + return useContext(Context) } export function useDialogControl(): DialogOuterProps['control'] { - const id = React.useId() - const control = React.useRef({ + const id = useId() + const control = useRef({ open: () => {}, close: () => {}, }) const {activeDialogs} = useDialogStateContext() - React.useEffect(() => { + useEffect(() => { activeDialogs.current.set(id, control) return () => { // eslint-disable-next-line react-hooks/exhaustive-deps @@ -37,7 +44,7 @@ export function useDialogControl(): DialogOuterProps['control'] { } }, [id, activeDialogs]) - return React.useMemo( + return useMemo( () => ({ id, ref: control, -- cgit 1.4.1