Update dependency react-router-dom to v7#378
Open
mend-for-github-com[bot] wants to merge 1 commit into
Open
Conversation
a60f38b to
df08f43
Compare
df08f43 to
de9ef31
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR contains the following updates:
6.30.3→7.0.0By merging this PR, the issue #388 will be automatically resolved and closed:
Release Notes
remix-run/react-router (react-router-dom)
v7.0.0Compare Source
Date: 2024-11-21
Breaking Changes
Package Restructuring
react-router-dom,@remix-run/react,@remix-run/server-runtime, and@remix-run/routerhave been collapsed into thereact-routerpackagereact-router-domis still published in v7 as a re-export of everything fromreact-router@remix-run/cloudflare-pagesand@remix-run/cloudflare-workershave been collapsed into@react-router/cloudflarepackage`react-router-dom-v5-compatandreact-router-nativepackages are removed starting with v7Removed Adapter Re-exports
Remix v2 used to re-export all common
@remix-run/server-runtimeAPIs through the various runtime packages (node,cloudflare,deno) so that you wouldn't need an additional@remix-run/server-runtimedependency in yourpackage.json. With the collapsing of packages intoreact-router, these common APIs are now no longer re-exported through the runtime adapters. You should import all common APIs fromreact-router, and only import runtime-specific APIs from the runtime packages:Removed APIs
The following APIs have been removed in React Router v7:
jsondeferunstable_composeUploadHandlersunstable_createMemoryUploadHandlerunstable_parseMultipartFormDataMinimum Versions
React Router v7 requires the following minimum versions:
node@20installGlobalsmethod to polyfill thefetchAPIreact@18,react-dom@18Adopted Future Flag Behaviors
Remix and React Router follow an API Development Strategy leveraging "Future Flags" to avoid introducing a slew of breaking changes in a major release. Instead, breaking changes are introduced in minor releases behind a flag, allowing users to opt-in at their convenience. In the next major release, all future flag behaviors become the default behavior.
The following previously flagged behaviors are now the default in React Router v7:
future.v7_relativeSplatPathfuture.v7_startTransitionfuture.v7_fetcherPersistfuture.v7_normalizeFormMethodfuture.v7_partialHydrationfuture.v7_skipActionStatusRevalidationfuture.v3_fetcherPersistfuture.v3_relativeSplatPathfuture.v3_throwAbortReasonfuture.v3_singleFetchfuture.v3_lazyRouteDiscoveryfuture.v3_optimizeDepsVite Compiler
The Remix Vite plugin is the proper way to build full-stack SSR apps using React Router v7. The former
esbuild-based compiler is no longer available.Renamed
vitePluginandcloudflareDevProxyVitePluginFor Remix consumers migrating to React Router, the
vitePluginandcloudflareDevProxyVitePluginexports have been renamed and moved (#11904)Removed
manifestoptionFor Remix consumers migrating to React Router, the Vite plugin's
manifestoption has been removed. Themanifestoption been superseded by the more powerfulbuildEndhook since it's passed thebuildManifestargument. You can still write the build manifest to disk if needed, but you'll most likely find it more convenient to write any logic depending on the build manifest within thebuildEndhook itself. (#11573)If you were using the
manifestoption, you can replace it with abuildEndhook that writes the manifest to disk like this:Exposed Router Promises
Because React 19 will have first-class support for handling promises in the render pass (via
React.useanduseAction), we are now comfortable exposing the promises for the APIs that previously returnedundefined:useNavigate()useSubmit()useFetcher().loaduseFetcher().submituseRevalidator().revalidate()Other Notable Changes
routes.tsWhen using the React Router Vite plugin, routes are defined in
app/routes.ts. Route config is exported via theroutesexport, conforming to theRouteConfigtype. Route helper functionsroute,index, andlayoutare provided to make declarative type-safe route definitions easier.For Remix consumers migrating to React Router, you can still configure file system routing within
routes.tsusing the@react-router/fs-routespackage. A minimal route config that reproduces the default Remix setup looks like this:If you want to migrate from file system routing to config-based routes, you can mix and match approaches by spreading the results of the async
flatRoutesfunction into the array of config-based routes.If you were using Remix's
routesoption to use alternative file system routing conventions, you can adapt these to the newRouteConfigformat using@react-router/remix-config-routes-adapter.For example, if you were using Remix v1 route conventions in Remix v2, you can combine
@react-router/remix-config-routes-adapterwith@remix-run/v1-route-conventionto adapt this to React Router:Also note that, if you were using Remix's
routesoption to define config-based routes, you can also adapt these to the newRouteConfigformat using@react-router/remix-config-routes-adapterwith minimal code changes. While this makes for a fast migration path, we recommend migrating any config-based routes from Remix to the newRouteConfigformat since it's a fairly straightforward migration.Type-safety improvements
React Router now generates types for each of your route modules and passes typed props to route module component exports (#11961, #12019). You can access those types by importing them from
./+types/<route filename without extension>.See How To > Route Module Type Safety and Explanations > Type Safety for more details.
Prerendering
React Router v7 includes a new
prerenderconfig in the vite plugin to support SSG use-cases. This will pre-render your.htmland.datafiles at build time and so you can serve them statically at runtime from a running server or a CDN (#11539)Major Changes (
react-router)deferimplementation in favor of using raw promises via single fetch andturbo-stream(#11744)deferAbortedDeferredErrortype TypedDeferredDataUNSAFE_DeferredDataUNSAFE_DEFERRED_SYMBOLreact-router(#11505)@remix-run/routerreact-router-dom@remix-run/server-runtime@remix-run/testingreact-router-dompackage is maintained to ease adoption but it simply re-exports all APIs fromreact-routerfuture.v7_startTransitionflag (#11696)future.v7_normalizeFormMethodfuture flag (#11697)@remix-run/routerAgnosticDataIndexRouteObjectAgnosticDataNonIndexRouteObjectAgnosticDataRouteMatchAgnosticDataRouteObjectAgnosticIndexRouteObjectAgnosticNonIndexRouteObjectAgnosticRouteMatchAgnosticRouteObjectTrackedPromiseunstable_AgnosticPatchRoutesOnMissFunctionAction-> exported asNavigationTypeviareact-routerRouterexported asRemixRouterto differentiate from RR's<Router>getToPathname(@private)joinPaths(@private)normalizePathname(@private)resolveTo(@private)stripBasename(@private)createBrowserHistory-> in favor ofcreateBrowserRoutercreateHashHistory-> in favor ofcreateHashRoutercreateMemoryHistory-> in favor ofcreateMemoryRoutercreateRoutercreateStaticHandler-> in favor of wrappercreateStaticHandlerin RR DomgetStaticContextFromErrorreact-routerHashPathnameSearchfuture.v7_prependBasenamefrom the internalized@remix-run/routerpackage (#11726)future.v7_throwAbortReasonfrom internalized@remix-run/routerpackage (#11728)exportsfield to all packages (#11675)RemixContexttoFrameworkContext(#11705)PrefetchPageDescriptorreplaced byPageLinkDescriptor(#11960)future.v7_partialHydrationflag (#11725)<RouterProvider fallbackElement>propfallbackElementto ahydrateFallbackElement/HydrateFallbackon your root routefuture.v7_partialHydration(when usingfallbackElement),state.navigationwas populated during the initial loadfuture.v7_partialHydration,state.navigationremains in an"idle"state during the initial loadfuture.v7_relativeSplatPathfuture flag (#11695)v7_skipActionErrorRevalidationv3_fetcherPersist,v3_relativeSplatPath,v3_throwAbortReasoncreateRemixStubtocreateRoutesStub(#11692)@remix-run/routerdeprecateddetectErrorBoundaryoption in favor ofmapRouteProperties(#11751)react-router/domsubpath export to properly enablereact-domas an optionalpeerDependency(#11851)import ReactDOM from "react-dom"in<RouterProvider>in order to accessReactDOM.flushSync(), since that would breakcreateMemoryRouteruse cases in non-DOM environmentsreact-router/domto get the proper component that makesReactDOM.flushSync()available:entry.client.tsx:import { HydratedRouter } from 'react-router/dom'createBrowserRouter/createHashRouter:import { RouterProvider } from "react-router/dom"future.v7_fetcherPersistflag (#11731)undefinedfrom loaders and actions (#11680, #12057)createRemixRouter/RouterProviderinentry.clientinstead ofRemixBrowser(#11469)jsonutility (#12146)Response.jsonif you still need to construct JSON responses in your appMajor Changes (
@react-router/*)future.v3_singleFetchflag (#11522)installGlobals()as this should no longer be necessaryexportsfield to all packages (#11675)react-routerthrough different runtime/adapter packages (#11702)cryptoglobal from the Web Crypto API is now required when using cookie and session APIsreact-routerrather than platform-specific packages: (#11837)createCookiecreateCookieSessionStoragecreateMemorySessionStoragecreateSessionStorageinstallGlobalsfunction from@remix-run/nodehas been updated to defineglobalThis.crypto, using Node'srequire('node:crypto').webcryptoimplementationcreateCookieFactorycreateSessionStorageFactorycreateCookieSessionStorageFactorycreateMemorySessionStorageFactory@remix-run/router,@remix-run/server-runtime, and@remix-run/reactnow that they all live inreact-router(#12177)LoaderFunction,LoaderFunctionArgs,ActionFunction,ActionFunctionArgs,DataFunctionArgs,RouteManifest,LinksFunction,Route,EntryRouteRouteManifesttype used by the "remix" code is now slightly stricter because it is using the former@remix-run/routerRouteManifestRecord<string, Route> -> Record<string, Route | undefined>AppDatatype in favor of inliningunknownin the few locations it was usedServerRuntimeMeta*types in favor of theMeta*types they were duplicated fromRoute.*typesRoute.*typesuseFetcherpreviously had an optional generic (used primarily by Remix v2) that expected the data typetypeof loader/typeof action)useFetcher<LoaderData>()useFetcher<typeof loader>()cookiedependency to^1.0.1- please see the release notes for any breaking changes (#12172)@react-router/cloudflare- For Remix consumers migrating to React Router, all exports from@remix-run/cloudflare-pagesare now provided for React Router consumers in the@react-router/cloudflarepackage. There is no longer a separate package for Cloudflare Pages. (#11801)@react-router/cloudflare- The@remix-run/cloudflare-workerspackage has been deprecated. Remix consumers migrating to React Router should use the@react-router/cloudflarepackage directly. For guidance on how to use@react-router/cloudflarewithin a Cloudflare Workers context, refer to the Cloudflare Workers template. (#11801)@react-router/dev- For Remix consumers migrating to React Router, thevitePluginandcloudflareDevProxyVitePluginexports have been renamed and moved. (#11904)@react-router/dev- For Remix consumers migrating to React Router who used the Vite plugin'sbuildEndhook, the resolvedreactRouterConfigobject no longer contains apublicPathproperty since this belongs to Vite, not React Router (#11575)@react-router/dev- For Remix consumers migrating to React Router, the Vite plugin'smanifestoption has been removed (#11573)@react-router/dev- Update defaultisbotversion to v5 and drop support forisbot@3(#11770)isbot@4orisbot@5in yourpackage.json:isbot@3in yourpackage.jsonand you have your ownentry.server.tsxfile in your repoisbot@5independent of the React Router v7 upgradeisbot@3in yourpackage.jsonand you do not have your ownentry.server.tsxfile in your repoisbot@5in yourpackage.json@react-router/dev- For Remix consumers migrating to React Router, Vite manifests (i.e..vite/manifest.json) are now written within each build subdirectory, e.g.build/client/.vite/manifest.jsonandbuild/server/.vite/manifest.jsoninstead ofbuild/.vite/client-manifest.jsonandbuild/.vite/server-manifest.json. This means that the build output is now much closer to what you'd expect from a typical Vite project. (#11573)build/.vitedirectory to avoid accidentally serving them in production, particularly from the client build. This was later improved with additional logic that deleted these Vite manifest files at the end of the build process unless Vite'sbuild.manifesthad been enabled within the app's Vite config. This greatly reduced the risk of accidentally serving the Vite manifests in production since they're only present when explicitly asked for. As a result, we can now assume that consumers will know that they need to manage these additional files themselves, and React Router can safely generate a more standard Vite build output.Minor Changes
react-router- Params, loader data, and action data as props for route component exports (#11961)react-router- Add route module type generation (#12019)react-router- Remove duplicateRouterProviderimplementations (#11679)react-router- Stabilizeunstable_dataStrategy(#11969)react-router- Stabilizeunstable_patchRoutesOnNavigation(#11970)react-router- Add prefetching support toLink/NavLinkwhen using Remix SSR (#11402)react-router- EnhanceScrollRestorationso it can restore properly on an SSR'd document load (#11401)@react-router/dev- Add support for theprerenderconfig in the React Router vite plugin, to support existing SSG use-cases (#11539)@react-router/dev- Remove internalentry.server.spa.tsximplementation which was not compatible with the Single Fetch async hydration approach (#11681)@react-router/serve: Updateexpress.staticconfigurations to support newprerenderAPI (#11547)build/client/assetsfolder are served as before, with a 1-year immutableCache-Controlheader.htmland.datafiles are not served with a specificCache-Controlheader.datafiles are served withContent-Type: text/x-turboexpress.static, it seems to also add aCache-Control: public, max-age=0to.datafilesPatch Changes
substrwithsubstring(#12080)react-router- Fix redirects returned from loaders/actions usingdata()(#12021)@react-router/dev- Enable prerendering for resource routes (#12200)@react-router/dev- resolve config directory relative to flat output file structure (#12187)Changes by Package
react-router@react-router/architect@react-router/cloudflare@react-router/dev@react-router/express@react-router/fs-routes@react-router/node@react-router/remix-config-routes-adapter@react-router/serveFull Changelog:
v6.28.0...v7.0.0v6.30.4Compare Source