Skip to content

Commit c930aed

Browse files
committed
Docs updates
1 parent f5dccaa commit c930aed

File tree

11 files changed

+29
-32
lines changed

11 files changed

+29
-32
lines changed

docs/api.md

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ order: 2
77

88
React Router is a collection of [React components](https://reactjs.org/docs/components-and-props.html), [hooks](https://reactjs.org/docs/hooks-intro.html) and utilities that make it easy to build multi-page applications with [React](https://reactjs.org). This reference contains the function signatures and return types of the various interfaces in React Router.
99

10-
<docs-info>Please refer to [our guides](./guides/index.md) for more in-depth usage examples of how you can use React Router to accomplish specific tasks.</docs-info>
11-
1210
## Overview
1311

1412
### Packages
@@ -45,7 +43,6 @@ A few low-level pieces that we use internally are also exposed as public API, in
4543

4644
- [`matchPath`](#matchpath) - matches a path pattern against a URL pathname
4745
- [`matchRoutes`](#matchroutes) - matches a set of routes against a [location](#location)
48-
- [`createRoutesFromArray`](#createroutesfromarray) - creates a route config from a set of plain JavaScript objects
4946
- [`createRoutesFromChildren`](#createroutesfromchildren) - creates a route config from a set of React elements (i.e. [`<Route>`](#routes-and-route) elements)
5047

5148
### Navigation
@@ -96,8 +93,8 @@ interface BrowserRouterProps {
9693
`<BrowserRouter window>` defaults to using the current [document's `defaultView`](https://developer.mozilla.org/en-US/docs/Web/API/Document/defaultView), but it may also be used to track changes to another's window's URL, in an `<iframe>`, for example.
9794

9895
```tsx
99-
import React from "react";
100-
import ReactDOM from "react-dom";
96+
import * as React from "react";
97+
import * as ReactDOM from "react-dom";
10198
import { BrowserRouter } from "react-router-dom";
10299

103100
ReactDOM.render(
@@ -132,8 +129,8 @@ interface HashRouterProps {
132129
`<HashRouter window>` defaults to using the current [document's `defaultView`](https://developer.mozilla.org/en-US/docs/Web/API/Document/defaultView), but it may also be used to track changes to another window's URL, in an `<iframe>`, for example.
133130

134131
```tsx
135-
import React from "react";
136-
import ReactDOM from "react-dom";
132+
import * as React from "react";
133+
import * as ReactDOM from "react-dom";
137134
import { HashRouter } from "react-router-dom";
138135

139136
ReactDOM.render(
@@ -167,7 +164,7 @@ interface NativeRouterProps extends MemoryRouterProps {}
167164
- `<NativeRouter initialIndex>` defaults to the last index of `props.initialEntries`
168165

169166
```tsx
170-
import React from "react";
167+
import * as React from "react";
171168
import { NativeRouter } from "react-router-native";
172169

173170
function App() {
@@ -211,7 +208,7 @@ A `<MemoryRouter>` stores its locations internally in an array. Unlike `<Browser
211208
> [browsing through our tests](https://github.com/remix-run/react-router/tree/main/packages/react-router/__tests__).
212209
213210
```tsx
214-
import React from "react";
211+
import * as React from "react";
215212
import { create } from "react-test-renderer";
216213
import {
217214
MemoryRouter,
@@ -268,7 +265,7 @@ type To = Partial<Location> | string;
268265
A `<Link>` is an element that lets the user navigate to another page by clicking or tapping on it. In `react-router-dom`, a `<Link>` renders an accessible `<a>` element with a real `href` that points to the resource it's linking to. This means that things like right-clicking a `<Link>` work as you'd expect.
269266

270267
```tsx
271-
import React from "react";
268+
import * as React from "react";
272269
import { Link } from "react-router-dom";
273270

274271
function UsersIndexPage({ users }) {
@@ -323,7 +320,7 @@ interface LinkProps extends TouchableHighlightProps {
323320
A `<Link>` is an element that lets the user navigate to another view by tapping it, similar to how `<a>` elements work in a web app. In `react-router-native`, a `<Link>` renders a `TouchableHighlight`.
324321

325322
```tsx
326-
import React from "react";
323+
import * as React from "react";
327324
import { View, Text } from "react-native";
328325
import { Link } from "react-router-native";
329326

@@ -369,7 +366,7 @@ A `<NavLink>` is a special kind of [`<Link>`](#link) that knows whether or not i
369366
By default, an `active` class is added to a `<NavLink>` component when it is active. This provides the same simple styling mechanism for most users who are upgrading from v5. One difference as of `v6.0.0-beta.3` is that `activeClassName` and `activeStyle` have been removed from `NavLinkProps`. Instead, you can pass a function to either `style` or `className` that will allow you to customize the inline styling or the class string based on the component's active state.
370367

371368
```tsx
372-
import React from "react";
369+
import * as React from "react";
373370
import { NavLink } from "react-router-dom";
374371

375372
function NavList() {
@@ -411,7 +408,7 @@ function NavList() {
411408
If you prefer the v5 API, you can create your own `<NavLink />` as a wrapper component:
412409

413410
```tsx
414-
import React from "react";
411+
import * as React from "react";
415412
import { NavLink as BaseNavLink } from "react-router-dom";
416413

417414
const NavLink = React.forwardRef(
@@ -472,7 +469,7 @@ A `<Navigate>` element changes the current location when it is rendered. It's a
472469
> subclass where hooks are not able to be used.
473470
474471
```tsx
475-
import React from "react";
472+
import * as React from "react";
476473
import { Navigate } from "react-router-dom";
477474

478475
class LoginForm extends React.Component {
@@ -666,8 +663,8 @@ interface StaticRouterProps {
666663
- `<StaticRouter location>` defaults to `"/"`
667664

668665
```tsx
669-
import React from "react";
670-
import ReactDOMServer from "react-dom/server";
666+
import * as React from "react";
667+
import * as ReactDOMServer from "react-dom/server";
671668
import { StaticRouter } from "react-router-dom/server";
672669
import http from "http";
673670

@@ -768,7 +765,7 @@ The term "location" in React Router refers to [the `Location` interface](https:/
768765

769766
> **Note:**
770767
>
771-
> The history package is React Router's main dependency and many of the
768+
> The `history` package is React Router's only dependency and many of the
772769
> core types in React Router come directly from that library including
773770
> `Location`, `To`, `Path`, `State`, and others. You can read more about
774771
> the history library in [its documentation](https://github.com/remix-run/history/tree/main/docs).
@@ -1042,7 +1039,7 @@ interface Location<S extends State = object | null>
10421039
This hook returns the current [`location`](#location) object. This can be useful if you'd like to perform some side effect whenever the current location changes.
10431040

10441041
```tsx
1045-
import React from 'react';
1042+
import * as React from 'react';
10461043
import { useLocation } from 'react-router-dom';
10471044

10481045
function App() {
@@ -1161,7 +1158,7 @@ declare function useParams<
11611158
The `useParams` hook returns an object of key/value pairs of the dynamic params from the current URL that were matched by the `<Route path>`. Child routes inherit all params from their parent routes.
11621159

11631160
```tsx
1164-
import React from 'react';
1161+
import * as React from 'react';
11651162
import { Routes, Route, useParams } from 'react-router-dom';
11661163

11671164
function ProfilePage() {
@@ -1218,7 +1215,7 @@ The `useRoutes` hook is the functional equivalent of [`<Routes>`](#routes), but
12181215
The return value of `useRoutes` is either a valid React element you can use to render the route tree, or `null` if nothing matched.
12191216

12201217
```tsx
1221-
import React from "react";
1218+
import * as React from "react";
12221219
import { useRoutes } from "react-router-dom";
12231220

12241221
function App() {
@@ -1279,7 +1276,7 @@ interface URLSearchParamsSetter {
12791276
The `useSearchParams` hook is used to read and modify the query string in the URL for the current location. Like React's own [`useState` hook](https://reactjs.org/docs/hooks-reference.html#usestate), `useSearchParams` returns an array of two values: the current location's [search params](https://developer.mozilla.org/en-US/docs/Web/API/URL/searchParams) and a function that may be used to update them.
12801277

12811278
```tsx
1282-
import React from "react";
1279+
import * as React from "react";
12831280
import { useSearchParams } from "react-router-dom";
12841281

12851282
function App() {
@@ -1345,7 +1342,7 @@ interface URLSearchParamsSetter {
13451342
The `useSearchParams` hook is used to read and modify the query string in the URL for the current location. Like React's own [`useState` hook](https://reactjs.org/docs/hooks-reference.html#usestate), `useSearchParams` returns an array of two values: the current location's [search params](https://developer.mozilla.org/en-US/docs/Web/API/URL/searchParams) and a function that may be used to update them.
13461343

13471344
```tsx
1348-
import React from "react";
1345+
import * as React from "react";
13491346
import { View, SearchForm, TextInput } from "react-native";
13501347
import { useSearchParams } from "react-router-native";
13511348

docs/examples/auth.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ Be sure to pay attention to the following features:
1717

1818
Open this example on [StackBlitz](https://stackblitz.com):
1919

20-
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/v6.0.0-beta.8/examples/auth?file=src/App.tsx)
20+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/main/examples/auth?file=src/App.tsx)

docs/examples/basic.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ This example demonstrates some of the basic features of React Router, including:
1818

1919
Open this example on [StackBlitz](https://stackblitz.com):
2020

21-
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/v6.0.0-beta.8/examples/basic?file=src/App.tsx)
21+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/main/examples/basic?file=src/App.tsx)

docs/examples/custom-filter-link.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ This example demonstrates how to use a query string parameter to mark a link as
1111

1212
Open this example on [StackBlitz](https://stackblitz.com):
1313

14-
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/v6.0.0-beta.8/examples/custom-filter-link?file=src/App.tsx)
14+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/main/examples/custom-filter-link?file=src/App.tsx)

docs/examples/custom-link.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ This example demonstrates how to make a custom `<Link>` component to render some
1111

1212
Open this example on [StackBlitz](https://stackblitz.com):
1313

14-
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/v6.0.0-beta.8/examples/custom-link?file=src/App.tsx)
14+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/main/examples/custom-link?file=src/App.tsx)

docs/examples/custom-query-parsing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ It's a good example of how React Router's low-level hooks provide you with all t
1313

1414
Open this example on [StackBlitz](https://stackblitz.com):
1515

16-
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/v6.0.0-beta.8/examples/custom-query-parsing?file=src/App.tsx)
16+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/main/examples/custom-query-parsing?file=src/App.tsx)

docs/examples/lazy-loading.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ performance.
1919

2020
Open this example on [StackBlitz](https://stackblitz.com):
2121

22-
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/v6.0.0-beta.8/examples/lazy-loading?file=src/App.tsx)
22+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/main/examples/lazy-loading?file=src/App.tsx)

docs/examples/modal.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ toc: false
99

1010
Open this example on [StackBlitz](https://stackblitz.com):
1111

12-
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/v6.0.0-beta.8/examples/modal?file=src/App.tsx)
12+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/main/examples/modal?file=src/App.tsx)

docs/examples/route-objects.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ One interesting thing to note is that even if you don't use this hook directly,
1313

1414
Open this example on [StackBlitz](https://stackblitz.com):
1515

16-
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/v6.0.0-beta.8/examples/route-objects?file=src/App.tsx)
16+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/main/examples/route-objects?file=src/App.tsx)

docs/examples/search-params.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ In this example, we have a form to search for a user on GitHub and display their
1313

1414
Open this example on [StackBlitz](https://stackblitz.com):
1515

16-
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/v6.0.0-beta.8/examples/search-params?file=src/App.tsx)
16+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/main/examples/search-params?file=src/App.tsx)

docs/examples/ssr.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ On the server (see [src/entry.server.tsx](src/entry.server.tsx)), we use React R
1919

2020
Open this example on [StackBlitz](https://stackblitz.com):
2121

22-
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/v6.0.0-beta.8/examples/ssr?file=src/App.tsx)
22+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router/tree/main/examples/ssr?file=src/App.tsx)

0 commit comments

Comments
 (0)