Unverified Commit 7852586e authored by 루밀LuMir's avatar 루밀LuMir Committed by GitHub

docs(javascript): fix wrong javascript code and a typo in `link.mdx` (#71143)

## 📚 Improving Documentation

Hello, I've fixed some incorrect javascript code and a typo in
[`link.mdx`](https://nextjs.org/docs/app/api-reference/components/link).

I made a few changes:

~~### 1. Changed `app/blog/page` to `app/blog/[slug]/page`~~

~~I believe it is accurate to include `[slug]` in the path.~~

### 2.  Added `export default`

The code block was missing `export default`, so I added it.

### 3. Corrected missing punctuation

### 4. Added `'use client`'

I think it is appropriate to add `'use client'` because the component
uses a client-side hook (`useIsAuthed`) that relies on client state,
which requires the component to be rendered on the client side.

---------
Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
parent f3227dbb
......@@ -648,7 +648,7 @@ For example, you can generate a list of links to the dynamic route `app/blog/[sl
```tsx filename="app/blog/page.tsx" switcher
import Link from 'next/link'
function Page({ posts }) {
export default function Page({ posts }) {
return (
<ul>
{posts.map((post) => (
......@@ -664,7 +664,7 @@ function Page({ posts }) {
```jsx filename="app/blog/page.js" switcher
import Link from 'next/link'
function Page({ posts }) {
export default function Page({ posts }) {
return (
<ul>
{posts.map((post) => (
......@@ -734,7 +734,7 @@ export default NavLink
```
- If you’re using [emotion](https://emotion.sh/)’s JSX pragma feature (`@jsx jsx`), you must use `passHref` even if you use an `<a>` tag directly.
- The component should support `onClick` property to trigger navigation correctly
- The component should support `onClick` property to trigger navigation correctly.
### Nesting a functional component
......@@ -1125,6 +1125,8 @@ In this case, you would want to use the following code in your `<Link />` compon
<AppOnly>
```tsx filename="app/page.tsx" switcher
'use client'
import Link from 'next/link'
import useIsAuthed from './hooks/useIsAuthed' // Your auth hook
......@@ -1140,6 +1142,8 @@ export default function Page() {
```
```js filename="app/page.js" switcher
'use client'
import Link from 'next/link'
import useIsAuthed from './hooks/useIsAuthed' // Your auth hook
......@@ -1159,6 +1163,8 @@ export default function Page() {
<PagesOnly>
```tsx filename="pages/index.tsx" switcher
'use client'
import Link from 'next/link'
import useIsAuthed from './hooks/useIsAuthed' // Your auth hook
......@@ -1174,6 +1180,8 @@ export default function Home() {
```
```js filename="pages/index.js" switcher
'use client'
import Link from 'next/link'
import useIsAuthed from './hooks/useIsAuthed' // Your auth hook
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment