mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-02 10:52:35 +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, {
|
|||
} from 'react';
|
||||
import {useThemeConfig, type DocsVersionPersistence} from '../useThemeConfig';
|
||||
import {isDocsPluginEnabled} from '../docsUtils';
|
||||
import {ReactContextError} from '../reactUtils';
|
||||
|
||||
import {
|
||||
useAllDocsData,
|
||||
|
@ -159,9 +160,7 @@ function DocsPreferredVersionContextProviderUnsafe({
|
|||
export function useDocsPreferredVersionContext(): DocsPreferredVersionContextValue {
|
||||
const value = useContext(Context);
|
||||
if (!value) {
|
||||
throw new Error(
|
||||
'Can\'t find docs preferred context, maybe you forgot to use the "DocsPreferredVersionContextProvider"?',
|
||||
);
|
||||
throw new ReactContextError('DocsPreferredVersionContextProvider');
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue