diff --git a/packages/console/src/pages/SignInExperience/tabs/Others/components/ManageLanguage/LanguageEditor/use-language-editor-context.ts b/packages/console/src/pages/SignInExperience/tabs/Others/components/ManageLanguage/LanguageEditor/use-language-editor-context.ts index 5b671a966..28ca0a61a 100644 --- a/packages/console/src/pages/SignInExperience/tabs/Others/components/ManageLanguage/LanguageEditor/use-language-editor-context.ts +++ b/packages/console/src/pages/SignInExperience/tabs/Others/components/ManageLanguage/LanguageEditor/use-language-editor-context.ts @@ -1,10 +1,7 @@ import type { LanguageTag } from '@logto/language-kit'; +import { noop } from '@silverhand/essentials'; import { createContext, useMemo, useState } from 'react'; -const noop = () => { - throw new Error('Context provider not found'); -}; - export type ConfirmationState = 'none' | 'try-close' | 'try-switch-language' | 'try-add-language'; export type Context = { diff --git a/packages/ui/src/containers/ConfirmModalProvider/index.tsx b/packages/ui/src/containers/ConfirmModalProvider/index.tsx index 32c51807a..5dd150285 100644 --- a/packages/ui/src/containers/ConfirmModalProvider/index.tsx +++ b/packages/ui/src/containers/ConfirmModalProvider/index.tsx @@ -1,4 +1,5 @@ import type { Nullable } from '@silverhand/essentials'; +import { noop } from '@silverhand/essentials'; import { useState, useRef, useMemo, createContext, useCallback } from 'react'; import type { ModalProps } from '@/components/ConfirmModal'; @@ -25,10 +26,6 @@ type ConfirmModalContextType = { cancel: (data?: unknown) => void; }; -const noop = () => { - throw new Error('Context provider not found'); -}; - export const ConfirmModalContext = createContext({ show: async () => [true], confirm: noop, diff --git a/packages/ui/src/hooks/use-page-context.ts b/packages/ui/src/hooks/use-page-context.ts index e24ea89b0..ce40853d4 100644 --- a/packages/ui/src/hooks/use-page-context.ts +++ b/packages/ui/src/hooks/use-page-context.ts @@ -1,3 +1,4 @@ +import { noop } from '@silverhand/essentials'; import { useState, useMemo, createContext } from 'react'; import { isMobile } from 'react-device-detect'; @@ -18,10 +19,6 @@ export type Context = { setExperienceSettings: React.Dispatch>; }; -const noop = () => { - throw new Error('Context provider not found'); -}; - export const PageContext = createContext({ toast: '', theme: 'light',