-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Add deprecation warnings for v7 flags in v6 #11750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d943c39
Add deprecation warnings for v7 flags in v6
brophdawg11 ce7fb1e
Fix re-exports tests
brophdawg11 607637b
Fix lint issues
brophdawg11 4f19e52
Bump bundle
brophdawg11 415612c
Add warning for skip action error revalidation
brophdawg11 2310940
Merge branch 'v6' into brophdawg11/v6-deprecations
brophdawg11 d7bf770
Bump bundle
brophdawg11 a3bd43f
Fix negation and separate warnings by data/non-data router
brophdawg11 0fa1874
Updates
brophdawg11 d96defd
Revert exmaples changes
brophdawg11 90276cb
Updates
brophdawg11 a2b48cf
Fix unit tests asserting against console warn
brophdawg11 c1490c0
Merge branch 'v6' into brophdawg11/v6-deprecations
brophdawg11 36e2658
Update links
brophdawg11 d1cdbac
Add deprecation annotations to json/defer
brophdawg11 3bcaf77
Apply suggestions from code review
brophdawg11 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.