Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(core): optimize App entrypoint, it should not re-render when navigating #10060

Merged
merged 2 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading