From 77a2030d8b8e61999bf037039ec571c63c987e53 Mon Sep 17 00:00:00 2001 From: Caleb Cox Date: Fri, 6 Sep 2024 12:43:42 -0500 Subject: [PATCH] Add default value to setup context This prevents tests that don't care about the setup context from having to mock it. --- src/components/Setup/SetupProvider.tsx | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/components/Setup/SetupProvider.tsx b/src/components/Setup/SetupProvider.tsx index b3f2ab7da..4ec1da508 100644 --- a/src/components/Setup/SetupProvider.tsx +++ b/src/components/Setup/SetupProvider.tsx @@ -20,18 +20,9 @@ export interface SetupContext { onSetupTour?: boolean; } -const SetupContext = createContext(null); +const SetupContext = createContext({ onSetupTour: undefined }); -export const useSetupContext = (): SetupContext => { - const setupContext = useContext(SetupContext); - if (!setupContext) { - throw new Error( - 'SetupProvider not found! Make sure that you are calling useSetupContext inside a component wrapped by .', - ); - } - - return setupContext; -}; +export const useSetupContext = (): SetupContext => useContext(SetupContext); // The list of page pathnames that are part of the setup tour const setupPages = new Set([