Skip to content

Commit

Permalink
Add default value to setup context
Browse files Browse the repository at this point in the history
This prevents tests that don't care about the setup context from having
to mock it.
  • Loading branch information
canac committed Sep 9, 2024
1 parent 86109a8 commit 77a2030
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/components/Setup/SetupProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,9 @@ export interface SetupContext {
onSetupTour?: boolean;
}

const SetupContext = createContext<SetupContext | null>(null);
const SetupContext = createContext<SetupContext>({ 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 <SetupProvider>.',
);
}

return setupContext;
};
export const useSetupContext = (): SetupContext => useContext(SetupContext);

// The list of page pathnames that are part of the setup tour
const setupPages = new Set([
Expand Down

0 comments on commit 77a2030

Please sign in to comment.