diff options
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/ActiveSectionProvider.tsx | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/components/ActiveSectionProvider.tsx b/src/components/ActiveSectionProvider.tsx index 0d491ac..bc6d111 100644 --- a/src/components/ActiveSectionProvider.tsx +++ b/src/components/ActiveSectionProvider.tsx | |||
@@ -26,9 +26,11 @@ const ActiveSectionContext = createContext<ActiveSection | undefined>( | |||
26 | export function useActiveSection(): ActiveSection { | 26 | export function useActiveSection(): ActiveSection { |
27 | const value = useContext(ActiveSectionContext); | 27 | const value = useContext(ActiveSectionContext); |
28 | if (value === undefined) { | 28 | if (value === undefined) { |
29 | throw new Error( | 29 | // Return fallback instead of signalling an error to avoid crashes in dev mode. |
30 | 'useActiveSection is only valid inside ActiveSectionProvider', | 30 | return { |
31 | ); | 31 | hash: undefined, |
32 | setHash: () => {}, | ||
33 | } | ||
32 | } | 34 | } |
33 | return value; | 35 | return value; |
34 | } | 36 | } |