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

docs: add an example for preload in effect #345

Merged
merged 5 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
19 changes: 19 additions & 0 deletions pages/docs/prefetching.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,25 @@ function App({ userId }) {
}
```

Inside React, you can call `preload` in effects.

```jsx
function App({ userId }) {
const [show, setShow] = useState(false)

useEffect(() => {
preload('/api/user?id=' + userId, fetcher)
}, [useId])

return (
<div>
<button onClick={() => setShow(true)}>Show User</button>
{show ? <User /> : null}
</div>
)
}
```

Together with techniques like [page prefetching](https://nextjs.org/docs/api-reference/next/router#routerprefetch) in Next.js, you will be able to load both next page and data instantly.

In Suspense mode, you should utilize `preload` to avoid waterfall problems.
Expand Down
19 changes: 19 additions & 0 deletions pages/docs/prefetching.es-ES.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,25 @@ function App({ userId }) {
}
```

Inside React, you can call `preload` in effects.

```jsx
function App({ userId }) {
const [show, setShow] = useState(false)

useEffect(() => {
preload('/api/user?id=' + userId, fetcher)
}, [useId])

return (
<div>
<button onClick={() => setShow(true)}>Show User</button>
{show ? <User /> : null}
</div>
)
}
```

Junto con técnicas como [page prefetching](https://nextjs.org/docs/api-reference/next/router#routerprefetch) en Next.js, podrás cargar tanto la siguiente página como los datos al instante.

In Suspense mode, you should utilize `preload` to avoid waterfall problems.
Expand Down
19 changes: 19 additions & 0 deletions pages/docs/prefetching.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,25 @@ function App({ userId }) {
}
```

React の内部においては, `preload` をエフェクトの中から呼ぶことができます。

```jsx
function App({ userId }) {
const [show, setShow] = useState(false)

useEffect(() => {
preload('/api/user?id=' + userId, fetcher)
}, [useId])

return (
<div>
<button onClick={() => setShow(true)}>Show User</button>
{show ? <User /> : null}
</div>
)
}
```

Next.js の [ページプリフェッチ](https://nextjs.org/docs/api-reference/next/router#routerprefetch) などの技術と合わせて、次のページとデータの両方を瞬時に読み込むことができるようになります。

サスペンスモードでは特に `preload` を利用してウォーターフォール問題を避けた方がいいでしょう。
Expand Down
19 changes: 19 additions & 0 deletions pages/docs/prefetching.ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,25 @@ function App({ userId }) {
}
```

Inside React, you can call `preload` in effects.

```jsx
function App({ userId }) {
const [show, setShow] = useState(false)

useEffect(() => {
preload('/api/user?id=' + userId, fetcher)
}, [useId])

return (
<div>
<button onClick={() => setShow(true)}>Show User</button>
{show ? <User /> : null}
</div>
)
}
```

Next.js내의 [페이지 프리패칭](https://nextjs.org/docs/api-reference/next/router#routerprefetch)같은 기술과 함께 다음 페이지와 데이터 모두를 즉시 로드할 수 있습니다.

In Suspense mode, you should utilize `preload` to avoid waterfall problems.
Expand Down
19 changes: 19 additions & 0 deletions pages/docs/prefetching.pt-BR.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,25 @@ function App({ userId }) {
}
```

Inside React, you can call `preload` in effects.

```jsx
function App({ userId }) {
const [show, setShow] = useState(false)

useEffect(() => {
preload('/api/user?id=' + userId, fetcher)
}, [useId])

return (
<div>
<button onClick={() => setShow(true)}>Show User</button>
{show ? <User /> : null}
</div>
)
}
```

Junto com técnicas como [page prefetching](https://nextjs.org/docs/api-reference/next/router#routerprefetch) no Next.js, você vai ser capaz de carregar ambos a próxima página e os dados instantaneamente.

In Suspense mode, you should utilize `preload` to avoid waterfall problems.
Expand Down
19 changes: 19 additions & 0 deletions pages/docs/prefetching.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,25 @@ function App({ userId }) {
}
```

Inside React, you can call `preload` in effects.

```jsx
function App({ userId }) {
const [show, setShow] = useState(false)

useEffect(() => {
preload('/api/user?id=' + userId, fetcher)
}, [useId])

return (
<div>
<button onClick={() => setShow(true)}>Show User</button>
{show ? <User /> : null}
</div>
)
}
```

Вместе с такими техниками, как [предзагрузка страниц](https://nextjs.org/docs/api-reference/next/router#routerprefetch) в Next.js, вы сможете мгновенно загружать как следующую страницу, так и данные.

In Suspense mode, you should utilize `preload` to avoid waterfall problems.
Expand Down
19 changes: 19 additions & 0 deletions pages/docs/prefetching.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,25 @@ function App({ userId }) {
}
```

Inside React, you can call `preload` in effects.

```jsx
function App({ userId }) {
const [show, setShow] = useState(false)

useEffect(() => {
preload('/api/user?id=' + userId, fetcher)
}, [useId])

return (
<div>
<button onClick={() => setShow(true)}>Show User</button>
{show ? <User /> : null}
</div>
)
}
```

配合 Next.js 的 [页面预加载](https://nextjs.org/docs/api-reference/next/router#routerprefetch),你将能立即加载下一页和数据。

In Suspense mode, you should utilize `preload` to avoid waterfall problems.
Expand Down