From d7c16ed3a801946e1d32b4b5a8a7d5b15876b87f Mon Sep 17 00:00:00 2001 From: Brooks Lybrand Date: Tue, 3 Dec 2024 15:00:51 -0600 Subject: [PATCH] docs: add section on `json` and `defer` being deprecated --- docs/upgrading/v6.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/upgrading/v6.md b/docs/upgrading/v6.md index c1e536ed3f..3902d1af38 100644 --- a/docs/upgrading/v6.md +++ b/docs/upgrading/v6.md @@ -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. @@ -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