Skip to content

Commit

Permalink
refactor: use react-router-dom import instead of history or `reac…
Browse files Browse the repository at this point in the history
…t-router` where possible
  • Loading branch information
MichaelDeBoey committed Jun 7, 2022
1 parent bc1ee1d commit 4ff8652
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 34 deletions.
4 changes: 0 additions & 4 deletions packages/remix-react/__tests__/transition-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1809,10 +1809,6 @@ describe("navigating with inflight fetchers", () => {
});
});

// describe("react-router", () => {
// it.todo("replaces pending locations even on a push");
// });

////////////////////////////////////////////////////////////////////////////////
type Deferred = ReturnType<typeof defer>;

Expand Down
2 changes: 1 addition & 1 deletion packages/remix-react/browser.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// TODO: We eventually might not want to import anything directly from `history`
// and leverage `react-router` here instead
// and leverage `react-router-dom` here instead
import type { BrowserHistory, Update } from "history";
import { createBrowserHistory } from "history";
import type { ReactElement } from "react";
Expand Down
13 changes: 9 additions & 4 deletions packages/remix-react/components.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
// TODO: We eventually might not want to import anything directly from `history`
// and leverage `react-router` here instead
import type { Action, Location } from "history";
// and leverage `react-router-dom` here instead
import type { Action } from "history";
import type {
FocusEventHandler,
FormHTMLAttributes,
MouseEventHandler,
TouchEventHandler,
} from "react";
import * as React from "react";
import type { Navigator, Params } from "react-router";
import type {
LinkProps,
Location,
NavLinkProps,
Navigator,
Params,
} from "react-router-dom";
import {
Router,
Link as RouterLink,
Expand All @@ -19,7 +25,6 @@ import {
useHref,
useResolvedPath,
} from "react-router-dom";
import type { LinkProps, NavLinkProps } from "react-router-dom";

import type { AppData, FormEncType, FormMethod } from "./data";
import type { EntryContext, AssetsManifest } from "./entry";
Expand Down
4 changes: 1 addition & 3 deletions packages/remix-react/errorBoundaries.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// TODO: We eventually might not want to import anything directly from `history`
// and leverage `react-router` here instead
import type { Location } from "history";
import type { Location } from "react-router-dom";
import React, { useContext } from "react";

import type {
Expand Down
11 changes: 4 additions & 7 deletions packages/remix-react/links.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
// TODO: We eventually might not want to import anything directly from `history`
// and leverage `react-router` here instead
import type { Location } from "history";
import { parsePath } from "history";
import type { Location } from "react-router-dom";
import { parsePath } from "react-router-dom";

import type { AssetsManifest } from "./entry";
import type { ClientRoute } from "./routes";
import type { RouteMatch } from "./routeMatching";
// import { matchClientRoutes } from "./routeMatching";
import type { RouteModules, RouteModule } from "./routeModules";
import type { RouteModule, RouteModules } from "./routeModules";
import { loadRouteModule } from "./routeModules";
import type { ClientRoute } from "./routes";

type Primitive = null | undefined | string | number | boolean | symbol | bigint;

Expand Down
5 changes: 1 addition & 4 deletions packages/remix-react/routeMatching.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
// TODO: We eventually might not want to import anything directly from `history`
// and leverage `react-router` here instead
import type { Location } from "history";
import type { Params, RouteObject } from "react-router"; // TODO: export/import from react-router-dom
import type { Location, Params, RouteObject } from "react-router-dom";
import { matchRoutes } from "react-router-dom";

import type { ClientRoute } from "./routes";
Expand Down
5 changes: 1 addition & 4 deletions packages/remix-react/routeModules.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// TODO: We eventually might not want to import anything directly from `history`
// and leverage `react-router` here instead
import type { Location } from "history";
import type { ComponentType } from "react";
import type { Params } from "react-router"; // TODO: import/export from react-router-dom
import type { Location, Params } from "react-router-dom";

import type { AppData } from "./data";
import type { LinkDescriptor } from "./links";
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-react/routes.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ComponentType, ReactNode } from "react";
import * as React from "react";
import type { Params } from "react-router";
import type { Params } from "react-router-dom";

import type { RouteModules, ShouldReloadFunction } from "./routeModules";
import { loadRouteModule } from "./routeModules";
Expand Down
4 changes: 1 addition & 3 deletions packages/remix-react/server.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// TODO: We eventually might not want to import anything directly from `history`
// and leverage `react-router` here instead
import type { Location, To } from "history";
import { Action, createPath } from "history";
import type { ReactElement } from "react";
import * as React from "react";
import type { Location, To } from "react-router-dom";

import { RemixEntry } from "./components";
import type { EntryContext } from "./entry";
Expand Down
4 changes: 2 additions & 2 deletions packages/remix-react/transition.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// TODO: We eventually might not want to import anything directly from `history`
// and leverage `react-router` here instead
// and leverage `react-router-dom` here instead
import { Action } from "history";
import type { Location } from "history";
import type { Location } from "react-router-dom";

import type { RouteData } from "./routeData";
import type { RouteMatch } from "./routeMatching";
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-server-runtime/routeMatching.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Params, RouteObject } from "react-router"; // TODO: export/import from react-router-dom
import type { Params, RouteObject } from "react-router-dom";
import { matchRoutes } from "react-router-dom";

import type { ServerRoute } from "./routes";
Expand Down

0 comments on commit 4ff8652

Please sign in to comment.