Skip to content

Commit

Permalink
chore: split up index.tsx file (#8686)
Browse files Browse the repository at this point in the history
* chore: extract lib/router.ts file

* chore: extract lib/context.ts file

* chore: extract lib/hooks.ts file

* chore: extract lib/components.tsx file

* chore: rename index.tsx -> index.ts

* chore: combine exports
  • Loading branch information
brophdawg11 committed Mar 4, 2022
1 parent dc37beb commit 1100224
Show file tree
Hide file tree
Showing 10 changed files with 1,565 additions and 1,419 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"rollup": "^1.27.9",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-copy": "^3.1.0",
"rollup-plugin-extensions": "^0.1.0",
"rollup-plugin-prettier": "^0.6.0",
"rollup-plugin-terser": "^7.0.2",
"semver": "^7.3.5",
Expand Down
132 changes: 132 additions & 0 deletions packages/react-router/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import type { Hash, Location, Path, Pathname, Search, To } from "history";
import { Action as NavigationType, parsePath, createPath } from "history";

import type {
MemoryRouterProps,
NavigateProps,
OutletProps,
RouteProps,
PathRouteProps,
LayoutRouteProps,
IndexRouteProps,
RouterProps,
RoutesProps,
} from "./lib/components";
import {
createRoutesFromChildren,
renderMatches,
MemoryRouter,
Navigate,
Outlet,
Route,
Router,
Routes,
} from "./lib/components";
import type { Navigator } from "./lib/context";
import {
LocationContext,
NavigationContext,
RouteContext,
} from "./lib/context";
import type { NavigateFunction, NavigateOptions } from "./lib/hooks";
import {
useHref,
useInRouterContext,
useLocation,
useMatch,
useNavigationType,
useNavigate,
useOutlet,
useOutletContext,
useParams,
useResolvedPath,
useRoutes,
} from "./lib/hooks";
import type {
Params,
PathMatch,
PathPattern,
RouteMatch,
RouteObject,
} from "./lib/router";
import {
generatePath,
matchPath,
matchRoutes,
resolvePath,
} from "./lib/router";

// Expose react-router public API
export type {
Hash,
IndexRouteProps,
LayoutRouteProps,
Location,
MemoryRouterProps,
NavigateFunction,
NavigateOptions,
NavigateProps,
OutletProps,
PathMatch,
PathPattern,
PathRouteProps,
RouteMatch,
RouteObject,
RouteProps,
RouterProps,
RoutesProps,
Navigator,
Params,
Path,
Pathname,
Search,
To,
};
export {
MemoryRouter,
Navigate,
NavigationType,
Outlet,
Route,
Router,
Routes,
createPath,
createRoutesFromChildren,
generatePath,
matchPath,
matchRoutes,
parsePath,
renderMatches,
resolvePath,
useHref,
useInRouterContext,
useLocation,
useMatch,
useNavigate,
useNavigationType,
useOutlet,
useOutletContext,
useParams,
useResolvedPath,
useRoutes,
};

///////////////////////////////////////////////////////////////////////////////
// DANGER! PLEASE READ ME!
// We provide these exports as an escape hatch in the event that you need any
// routing data that we don't provide an explicit API for. With that said, we
// want to cover your use case if we can, so if you feel the need to use these
// we want to hear from you. Let us know what you're building and we'll do our
// best to make sure we can support you!
//
// We consider these exports an implementation detail and do not guarantee
// against any breaking changes, regardless of the semver release. Use with
// extreme caution and only if you understand the consequences. Godspeed.
///////////////////////////////////////////////////////////////////////////////

/** @internal */
export {
NavigationContext as UNSAFE_NavigationContext,
LocationContext as UNSAFE_LocationContext,
RouteContext as UNSAFE_RouteContext,
};

0 comments on commit 1100224

Please sign in to comment.