mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-23 19:48:54 +02:00
refactor(theme-common): unify missing context errors (#6826)
* refactor(theme-common): unify missing context errors * update test * more robust
This commit is contained in:
parent
5c60f41e1b
commit
c387a177e8
11 changed files with 35 additions and 28 deletions
|
@ -15,6 +15,7 @@ import React, {
|
|||
type ReactNode,
|
||||
} from 'react';
|
||||
import {createStorageSlot, listStorageKeys} from './storageUtils';
|
||||
import {ReactContextError} from './reactUtils';
|
||||
|
||||
const TAB_CHOICE_PREFIX = 'docusaurus.tab.';
|
||||
|
||||
|
@ -82,9 +83,7 @@ export function TabGroupChoiceProvider({
|
|||
export function useTabGroupChoice(): TabGroupChoiceContextValue {
|
||||
const context = useContext(TabGroupChoiceContext);
|
||||
if (context == null) {
|
||||
throw new Error(
|
||||
'"useUserPreferencesContext" is used outside of "Layout" component.',
|
||||
);
|
||||
throw new ReactContextError('TabGroupChoiceProvider');
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue