Skip to content

Commit

Permalink
docs(javascript): fix wrong javascript code and a typo in link.mdx (#…
Browse files Browse the repository at this point in the history
…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: JJ Kasper <jj@jjsweb.site>
  • Loading branch information
lumirlumir and ijjk authored Oct 12, 2024
1 parent f3227db commit 7852586
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions docs/02-app/02-api-reference/01-components/link.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => (
Expand All @@ -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) => (
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 7852586

Please sign in to comment.