-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add deprecation warnings for v7 flags in v6 (#11750)
- Loading branch information
1 parent
50c59ea
commit caa0895
Showing
13 changed files
with
155 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
"react-router-dom": minor | ||
"react-router": minor | ||
"@remix-run/router": minor | ||
--- | ||
|
||
- Log deprecation warnings for v7 flags | ||
- Add deprecation warnings to `json`/`defer` in favor of returning raw objects | ||
- These methods will be removed in React Router v7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import type { FutureConfig as RouterFutureConfig } from "@remix-run/router"; | ||
import type { FutureConfig as RenderFutureConfig } from "./components"; | ||
|
||
const alreadyWarned: { [key: string]: boolean } = {}; | ||
|
||
export function warnOnce(key: string, message: string): void { | ||
if (!alreadyWarned[message]) { | ||
alreadyWarned[message] = true; | ||
console.warn(message); | ||
} | ||
} | ||
|
||
const logDeprecation = (flag: string, msg: string, link: string) => | ||
warnOnce( | ||
flag, | ||
`⚠️ React Router Future Flag Warning: ${msg}. ` + | ||
`You can use the \`${flag}\` future flag to opt-in early. ` + | ||
`For more information, see ${link}.` | ||
); | ||
|
||
export function logV6DeprecationWarnings( | ||
renderFuture: Partial<RenderFutureConfig> | undefined, | ||
routerFuture?: Omit<RouterFutureConfig, "v7_prependBasename"> | ||
) { | ||
if (!renderFuture?.v7_startTransition) { | ||
logDeprecation( | ||
"v7_startTransition", | ||
"React Router will begin wrapping state updates in `React.startTransition` in v7", | ||
"https://reactrouter.com/v6/upgrading/future#v7_starttransition" | ||
); | ||
} | ||
|
||
if ( | ||
!renderFuture?.v7_relativeSplatPath && | ||
(!routerFuture || !routerFuture.v7_relativeSplatPath) | ||
) { | ||
logDeprecation( | ||
"v7_relativeSplatPath", | ||
"Relative route resolution within Splat routes is changing in v7", | ||
"https://reactrouter.com/v6/upgrading/future#v7_relativesplatpath" | ||
); | ||
} | ||
|
||
if (routerFuture) { | ||
if (!routerFuture.v7_fetcherPersist) { | ||
logDeprecation( | ||
"v7_fetcherPersist", | ||
"The persistence behavior of fetchers is changing in v7", | ||
"https://reactrouter.com/v6/upgrading/future#v7_fetcherpersist" | ||
); | ||
} | ||
|
||
if (!routerFuture.v7_normalizeFormMethod) { | ||
logDeprecation( | ||
"v7_normalizeFormMethod", | ||
"Casing of `formMethod` fields is being normalized to uppercase in v7", | ||
"https://reactrouter.com/v6/upgrading/future#v7_normalizeformmethod" | ||
); | ||
} | ||
|
||
if (!routerFuture.v7_partialHydration) { | ||
logDeprecation( | ||
"v7_partialHydration", | ||
"`RouterProvider` hydration behavior is changing in v7", | ||
"https://reactrouter.com/v6/upgrading/future#v7_partialhydration" | ||
); | ||
} | ||
|
||
if (!routerFuture.v7_skipActionErrorRevalidation) { | ||
logDeprecation( | ||
"v7_skipActionErrorRevalidation", | ||
"The revalidation behavior after 4xx/5xx `action` responses is changing in v7", | ||
"https://reactrouter.com/v6/upgrading/future#v7_skipactionerrorrevalidation" | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters