From 541292d8cc2a7e616609561fcf770e35a43aed61 Mon Sep 17 00:00:00 2001 From: p-sw Date: Fri, 24 May 2024 19:15:21 +0900 Subject: [PATCH] fix: add error message in set method of context on outside of provider --- packages/react/components/Dialog.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/react/components/Dialog.tsx b/packages/react/components/Dialog.tsx index 640f090..e6fedb4 100644 --- a/packages/react/components/Dialog.tsx +++ b/packages/react/components/Dialog.tsx @@ -20,7 +20,16 @@ interface DialogContext { const initialDialogContext: DialogContext = { opened: false }; const DialogContext = React.createContext< [DialogContext, Dispatch>] ->([initialDialogContext, () => {}]); +>([ + initialDialogContext, + () => { + if (process.env.NODE_ENV && process.env.NODE_ENV !== "development") { + console.warn( + "It seems like you're using DialogContext outside of a provider." + ); + } + }, +]); const useDialogContext = () => React.useContext(DialogContext);