Skip to content

Commit d7c16ed

Browse files
committed
docs: add section on json and defer being deprecated
1 parent efbe325 commit d7c16ed

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

docs/upgrading/v6.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,18 @@ function shouldRevalidate({ actionStatus, defaultShouldRevalidate }) {
293293
}
294294
```
295295

296+
## Deprecations
297+
298+
The `json` and `defer` methods are deprecated in favor of returning raw objects.
299+
300+
```diff
301+
async function loader() {
302+
- return json({ data });
303+
+ return { data };
304+
```
305+
306+
If you were using `json` to serialize your data to JSON, you can use the native [Response.json()][response-json] method instead.
307+
296308
## Upgrade to v7
297309

298310
Now that your app is caught up, you can simply update to v7 (theoretically!) without issue.
@@ -354,3 +366,5 @@ Note you should use a top-level import for non-DOM contexts, such as Jest tests:
354366
Congratulations, you're now on v7!
355367

356368
[react-flushsync]: https://react.dev/reference/react-dom/flushSync
369+
[response-json]: https://developer.mozilla.org/en-US/docs/Web/API/Response/json
370+
[data-util]: https://api.reactrouter.com/v7/functions/react_router.data.html

0 commit comments

Comments
 (0)