mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-03 19:32:35 +02:00
fix(v2): fix useEffect infinite loop in blogOnly mode (#5097)
This commit is contained in:
parent
ab3821cb39
commit
0f144213d6
1 changed files with 5 additions and 1 deletions
|
@ -24,11 +24,15 @@ import {
|
|||
GetActivePluginOptions,
|
||||
} from '../../client/docsClientUtils';
|
||||
|
||||
// Important to use a constant object to avoid React useEffect executions etc...,
|
||||
// see https://github.com/facebook/docusaurus/issues/5089
|
||||
const StableEmptyObject = {};
|
||||
|
||||
// Not using useAllPluginInstancesData() because in blog-only mode, docs hooks are still used by the theme
|
||||
// We need a fail-safe fallback when the docs plugin is not in use
|
||||
export const useAllDocsData = (): Record<string, GlobalPluginData> =>
|
||||
// useAllPluginInstancesData('docusaurus-plugin-content-docs');
|
||||
useGlobalData()['docusaurus-plugin-content-docs'] ?? {};
|
||||
useGlobalData()['docusaurus-plugin-content-docs'] ?? StableEmptyObject;
|
||||
|
||||
export const useDocsData = (pluginId: string | undefined): GlobalPluginData =>
|
||||
usePluginData('docusaurus-plugin-content-docs', pluginId) as GlobalPluginData;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue