Skip to content

Commit

Permalink
refactor(core): optimize App entrypoint, it should not re-render when…
Browse files Browse the repository at this point in the history
… navigating (#10060)
  • Loading branch information
slorber authored Apr 19, 2024
1 parent c746289 commit eb07e9d
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions packages/docusaurus/src/client/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,19 @@ import SiteMetadataDefaults from './SiteMetadataDefaults';
import ErrorBoundary from '@docusaurus/ErrorBoundary';
import HasHydratedDataAttribute from './hasHydratedDataAttribute';

export default function App(): JSX.Element {
const routeElement = renderRoutes(routes);
const routesElement = renderRoutes(routes);

function AppNavigation() {
const location = useLocation();
const normalizedLocation = normalizeLocation(location);
return (
<PendingNavigation location={normalizedLocation}>
{routesElement}
</PendingNavigation>
);
}

export default function App(): JSX.Element {
return (
<ErrorBoundary>
<DocusaurusContextProvider>
Expand All @@ -36,9 +46,7 @@ export default function App(): JSX.Element {
<SiteMetadataDefaults />
<SiteMetadata />
<BaseUrlIssueBanner />
<PendingNavigation location={normalizeLocation(location)}>
{routeElement}
</PendingNavigation>
<AppNavigation />
</Root>
<HasHydratedDataAttribute />
</BrowserContextProvider>
Expand Down

0 comments on commit eb07e9d

Please sign in to comment.