Skip to content

Commit 5080edb

Browse files
authored
[docs] fix missing-data-scroll-behavior doc (#84651)
Fixes the code snippets for this doc.
1 parent 22c5a06 commit 5080edb

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

errors/missing-data-scroll-behavior.mdx

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,28 @@ Next.js automatically attempts to detect the smooth scrolling configuration to e
1212

1313
Add `data-scroll-behavior="smooth"` to your `<html>` element if you want to disable smooth scrolling when routing via Next.js.
1414

15-
```html filename="app/layout.tsx"
16-
export default function RootLayout({ children, }: { children: React.ReactNode })
17-
{ return (
18-
<html lang="en" data-scroll-behavior="smooth">
19-
<body>
20-
{children}
21-
</body>
22-
</html>
23-
) }
15+
```tsx filename="app/layout.tsx" switcher
16+
export default function RootLayout({
17+
children,
18+
}: {
19+
children: React.ReactNode
20+
}) {
21+
return (
22+
<html lang="en" data-scroll-behavior="smooth">
23+
<body>{children}</body>
24+
</html>
25+
)
26+
}
2427
```
2528

26-
Or if you're using the Pages Router:
27-
28-
```html filename="pages/_document.tsx"
29-
import { Html, Head, Main, NextScript } from 'next/document' export default
30-
function Document() { return (
31-
<html lang="en" data-scroll-behavior="smooth">
32-
<head />
33-
<body>
34-
<main />
35-
<NextScript />
36-
</body>
37-
</html>
38-
) }
29+
```jsx filename="app/layout.js" switcher
30+
export default function RootLayout({ children }) {
31+
return (
32+
<html lang="en" data-scroll-behavior="smooth">
33+
<body>{children}</body>
34+
</html>
35+
)
36+
}
3937
```
4038

4139
## Why This Optimization Matters

0 commit comments

Comments
 (0)