Skip to content

Commit 19c524c

Browse files
authored
docs(utils/defer): Fix highlighting, and use defer instead of json (#5146)
1 parent ff4d869 commit 19c524c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/utils/defer.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ title: defer
66

77
This is a shortcut for creating a streaming/deferred response. It assumes you are using `utf-8` encoding. From a developer perspective it behaves just like [`json()`][json], but with the ability to transport promises to your UI components.
88

9-
```ts lines=[2,6]
9+
```ts lines=[2,5,10]
1010
import type { LoaderFunction } from "@remix-run/node"; // or cloudflare/deno
11-
import { json } from "@remix-run/node"; // or cloudflare/deno
11+
import { defer } from "@remix-run/node"; // or cloudflare/deno
1212

1313
export const loader: LoaderFunction = async () => {
1414
const aStillRunningPromise = loadSlowDataAsync();
1515

1616
// So you can write this without awaiting the promise:
17-
return json({
17+
return defer({
1818
critical: "data",
1919
slowPromise: aStillRunningPromise,
2020
});
@@ -23,7 +23,7 @@ export const loader: LoaderFunction = async () => {
2323

2424
You can also pass a status code and headers:
2525

26-
```ts lines=[4-9]
26+
```ts lines=[9-14]
2727
export const loader: LoaderFunction = async () => {
2828
const aStillRunningPromise = loadSlowDataAsync();
2929

0 commit comments

Comments
 (0)