Skip to content

Rename RemixRouter -> DataRouter #12062

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 2 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .changeset/gold-suns-march.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Imports/Exports cleanup
- `TrackedPromise`
- `unstable_AgnosticPatchRoutesOnMissFunction`
- `Action` -> exported as `NavigationType` via `react-router`
- `Router` exported as `RemixRouter` to differentiate from RR's `<Router>`
- `Router` exported as `DataRouter` to differentiate from RR's `<Router>`
- API
- `getToPathname` (`@private`)
- `joinPaths` (`@private`)
Expand Down
5 changes: 5 additions & 0 deletions .changeset/silly-papayas-trade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-router": patch
---

[REMOVE] Rename RemixRouter->DataRouter
2 changes: 1 addition & 1 deletion packages/react-router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type {
RelativeRoutingType,
Blocker,
BlockerFunction,
Router as RemixRouter,
Router as DataRouter,
RouterState,
RouterInit,
RouterSubscriber,
Expand Down
8 changes: 4 additions & 4 deletions packages/react-router/lib/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type {
FutureConfig,
HydrationState,
RelativeRoutingType,
Router as RemixRouter,
Router as DataRouter,
RouterState,
RouterSubscriber,
} from "./router/router";
Expand Down Expand Up @@ -144,7 +144,7 @@ export function createMemoryRouter(
dataStrategy?: DataStrategyFunction;
patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
}
): RemixRouter {
): DataRouter {
return createRouter({
basename: opts?.basename,
future: opts?.future,
Expand Down Expand Up @@ -187,7 +187,7 @@ class Deferred<T> {

// Copied from react-dom types
export interface RouterProviderProps {
router: RemixRouter;
router: DataRouter;
flushSync?: (fn: () => unknown) => undefined;
}

Expand Down Expand Up @@ -455,7 +455,7 @@ function DataRoutes({
state,
}: {
routes: DataRouteObject[];
future: RemixRouter["future"];
future: DataRouter["future"];
state: RouterState;
}): React.ReactElement | null {
return useRoutesImpl(routes, undefined, state, future);
Expand Down
10 changes: 4 additions & 6 deletions packages/react-router/lib/dom-export/hydrated-router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from "react";
import type {
UNSAFE_AssetsManifest as AssetsManifest,
UNSAFE_RouteModules as RouteModules,
createBrowserRouter,
DataRouter,
HydrationState,
} from "react-router";
import {
Expand All @@ -25,8 +25,6 @@ import {
} from "react-router";
import { RouterProvider } from "./dom-router-provider";

type RemixRouter = ReturnType<typeof createBrowserRouter>;

type SSRInfo = {
context: NonNullable<(typeof window)["__reactRouterContext"]>;
routeModules: RouteModules;
Expand All @@ -37,12 +35,12 @@ type SSRInfo = {
error?: unknown;
})
| undefined;
router: RemixRouter | undefined;
router: DataRouter | undefined;
routerInitialized: boolean;
};

let ssrInfo: SSRInfo | null = null;
let router: RemixRouter | null = null;
let router: DataRouter | null = null;

function initSsrInfo(): void {
if (
Expand All @@ -62,7 +60,7 @@ function initSsrInfo(): void {
}
}

function createHydratedRouter(): RemixRouter {
function createHydratedRouter(): DataRouter {
initSsrInfo();

if (!ssrInfo) {
Expand Down
4 changes: 2 additions & 2 deletions packages/react-router/lib/dom/global.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { HydrationState, Router as RemixRouter } from "../router/router";
import type { HydrationState, Router as DataRouter } from "../router/router";
import type { AssetsManifest, FutureConfig } from "./ssr/entry";
import type { RouteModules } from "./ssr/routeModules";

Expand Down Expand Up @@ -36,7 +36,7 @@ declare global {
var __reactRouterContext: WindowReactRouterContext | undefined;
var __reactRouterManifest: AssetsManifest | undefined;
var __reactRouterRouteModules: RouteModules | undefined;
var __reactRouterInstance: RemixRouter | undefined;
var __reactRouterInstance: DataRouter | undefined;
var __reactRouterHdrActive: boolean;
var __reactRouterClearCriticalCss: (() => void) | undefined;
var $RefreshRuntime$:
Expand Down
12 changes: 6 additions & 6 deletions packages/react-router/lib/dom/lib.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import type {
GetScrollRestorationKeyFunction,
HydrationState,
RelativeRoutingType,
Router as RemixRouter,
Router as DataRouter,
} from "../router/router";
import { IDLE_FETCHER, createRouter } from "../router/router";
import type {
Expand Down Expand Up @@ -136,7 +136,7 @@ interface DOMRouterOpts {
export function createBrowserRouter(
routes: RouteObject[],
opts?: DOMRouterOpts
): RemixRouter {
): DataRouter {
return createRouter({
basename: opts?.basename,
future: opts?.future,
Expand All @@ -156,7 +156,7 @@ export function createBrowserRouter(
export function createHashRouter(
routes: RouteObject[],
opts?: DOMRouterOpts
): RemixRouter {
): DataRouter {
return createRouter({
basename: opts?.basename,
future: opts?.future,
Expand All @@ -182,11 +182,11 @@ function parseHydrationData(): HydrationState | undefined {
}

function deserializeErrors(
errors: RemixRouter["state"]["errors"]
): RemixRouter["state"]["errors"] {
errors: DataRouter["state"]["errors"]
): DataRouter["state"]["errors"] {
if (!errors) return null;
let entries = Object.entries(errors);
let serialized: RemixRouter["state"]["errors"] = {};
let serialized: DataRouter["state"]["errors"] = {};
for (let [key, val] of entries) {
// Hey you! If you change this, please change the corresponding logic in
// serializeErrors in react-router-dom/server.tsx :)
Expand Down
8 changes: 4 additions & 4 deletions packages/react-router/lib/dom/server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from "../router/history";
import type {
FutureConfig,
Router as RemixRouter,
Router as DataRouter,
RevalidationState,
CreateStaticHandlerOptions as RouterCreateStaticHandlerOptions,
RouterState,
Expand Down Expand Up @@ -81,7 +81,7 @@ export function StaticRouter({

export interface StaticRouterProviderProps {
context: StaticHandlerContext;
router: RemixRouter;
router: DataRouter;
hydrate?: boolean;
nonce?: string;
}
Expand Down Expand Up @@ -171,7 +171,7 @@ function DataRoutes({
state,
}: {
routes: DataRouteObject[];
future: RemixRouter["future"];
future: DataRouter["future"];
state: RouterState;
}): React.ReactElement | null {
return useRoutesImpl(routes, undefined, state, future);
Expand Down Expand Up @@ -276,7 +276,7 @@ export function createStaticRouter(
opts: {
future?: Partial<FutureConfig>;
} = {}
): RemixRouter {
): DataRouter {
let manifest: RouteManifest = {};
let dataRoutes = convertRoutesToDataRoutes(
routes,
Expand Down
8 changes: 4 additions & 4 deletions packages/react-router/lib/dom/ssr/errors.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { Router as RemixRouter } from "../../router/router";
import type { RouterState } from "../../router/router";
import { ErrorResponseImpl } from "../../router/utils";

export function deserializeErrors(
errors: RemixRouter["state"]["errors"]
): RemixRouter["state"]["errors"] {
errors: RouterState["errors"]
): RouterState["errors"] {
if (!errors) return null;
let entries = Object.entries(errors);
let serialized: RemixRouter["state"]["errors"] = {};
let serialized: RouterState["errors"] = {};
for (let [key, val] of entries) {
// Hey you! If you change this, please change the corresponding logic in
// serializeErrors in react-router/lib/server-runtime/errors.ts :)
Expand Down
8 changes: 4 additions & 4 deletions packages/react-router/lib/dom/ssr/fog-of-war.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from "react";
import type { PatchRoutesOnNavigationFunction } from "../../context";
import type { Router as RemixRouter } from "../../router/router";
import type { Router as DataRouter } from "../../router/router";
import { matchRoutes } from "../../router/utils";
import type { AssetsManifest } from "./entry";
import type { RouteModules } from "./routeModules";
Expand Down Expand Up @@ -30,7 +30,7 @@ export function isFogOfWarEnabled(isSpaMode: boolean) {

export function getPartialManifest(
manifest: AssetsManifest,
router: RemixRouter
router: DataRouter
) {
// Start with our matches for this pathname
let routeIds = new Set(router.state.matches.map((m) => m.route.id));
Expand Down Expand Up @@ -91,7 +91,7 @@ export function getPatchRoutesOnNavigationFunction(
}

export function useFogOFWarDiscovery(
router: RemixRouter,
router: DataRouter,
manifest: AssetsManifest,
routeModules: RouteModules,
isSpaMode: boolean
Expand Down Expand Up @@ -203,7 +203,7 @@ export async function fetchAndApplyManifestPatches(
routeModules: RouteModules,
isSpaMode: boolean,
basename: string | undefined,
patchRoutes: RemixRouter["patchRoutes"]
patchRoutes: DataRouter["patchRoutes"]
): Promise<void> {
let manifestPath = `${basename != null ? basename : "/"}/__manifest`.replace(
/\/+/g,
Expand Down
6 changes: 3 additions & 3 deletions packages/react-router/lib/dom/ssr/single-fetch.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from "react";
import { decode } from "turbo-stream";
import type { Router as RemixRouter } from "../../router/router";
import type { Router as DataRouter } from "../../router/router";
import type {
DataStrategyFunction,
DataStrategyFunctionArgs,
Expand Down Expand Up @@ -133,7 +133,7 @@ export function StreamTransfer({
export function getSingleFetchDataStrategy(
manifest: AssetsManifest,
routeModules: RouteModules,
getRouter: () => RemixRouter
getRouter: () => DataRouter
): DataStrategyFunction {
return async ({ request, matches, fetcherKey }) => {
// Actions are simple and behave the same for navigations and fetchers
Expand Down Expand Up @@ -199,7 +199,7 @@ async function singleFetchActionStrategy(
async function singleFetchLoaderNavigationStrategy(
manifest: AssetsManifest,
routeModules: RouteModules,
router: RemixRouter,
router: DataRouter,
request: Request,
matches: DataStrategyFunctionArgs["matches"]
) {
Expand Down
10 changes: 5 additions & 5 deletions packages/react-router/lib/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import type {
Blocker,
BlockerFunction,
RelativeRoutingType,
Router as RemixRouter,
Router as DataRouter,
RevalidationState,
} from "./router/router";
import { IDLE_BLOCKER } from "./router/router";
Expand Down Expand Up @@ -436,8 +436,8 @@ export function useRoutes(
export function useRoutesImpl(
routes: RouteObject[],
locationArg?: Partial<Location> | string,
dataRouterState?: RemixRouter["state"],
future?: RemixRouter["future"]
dataRouterState?: DataRouter["state"],
future?: DataRouter["future"]
): React.ReactElement | null {
invariant(
useInRouterContext(),
Expand Down Expand Up @@ -767,8 +767,8 @@ function RenderedRoute({ routeContext, match, children }: RenderedRouteProps) {
export function _renderMatches(
matches: RouteMatch[] | null,
parentMatches: RouteMatch[] = [],
dataRouterState: RemixRouter["state"] | null = null,
future: RemixRouter["future"] | null = null
dataRouterState: DataRouter["state"] | null = null,
future: DataRouter["future"] | null = null
): React.ReactElement | null {
if (matches == null) {
if (!dataRouterState) {
Expand Down