Skip to content

Commit

Permalink
docs: add section on json and defer being deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
brookslybrand committed Dec 3, 2024
1 parent efbe325 commit d7c16ed
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docs/upgrading/v6.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,18 @@ function shouldRevalidate({ actionStatus, defaultShouldRevalidate }) {
}
```

## Deprecations

The `json` and `defer` methods are deprecated in favor of returning raw objects.

```diff
async function loader() {
- return json({ data });
+ return { data };
```

If you were using `json` to serialize your data to JSON, you can use the native [Response.json()][response-json] method instead.

## Upgrade to v7

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

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

0 comments on commit d7c16ed

Please sign in to comment.