Skip to content

Commit

Permalink
docs: cleanup small grammar mistakes and make how-tos more similar
Browse files Browse the repository at this point in the history
  • Loading branch information
brookslybrand committed Nov 21, 2024
1 parent 9272911 commit 3f102fc
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 36 deletions.
4 changes: 2 additions & 2 deletions docs/explanation/race-conditions.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ React Router's handling of network concurrency is heavily inspired by the behavi
Consider clicking a link to a new document, and then clicking a different link before the new page has finished loading. The browser will:

1. cancel the first request
2. immediately processes the new navigation
2. immediately process the new navigation

This behavior includes form submissions. When a pending form submission is interrupted by a new one, the first is canceled and the new submission is immediately processed.
The same behavior applies to form submissions. When a pending form submission is interrupted by a new one, the first is canceled and the new submission is immediately processed.

## React Router Behavior

Expand Down
2 changes: 1 addition & 1 deletion docs/explanation/type-safety.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ title: Type Safety

If you haven't done so already, check out our guide for [setting up type safety][route-module-type-safety] in a new project.

React Router generates types for each route in your app that you can use to get type safety for each route module export.
React Router generates types for each route in your app that provide type safety for the route module exports.

For example, let's say you have a `products/:id` route configured:

Expand Down
4 changes: 2 additions & 2 deletions docs/how-to/fetchers.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default function Component() {

### 3. Submit the form

If you submit the form now, the fetcher call the action and revalidate the route data automatically.
If you submit the form now, the fetcher will call the action and revalidate the route data automatically.

### 4. Render pending state

Expand Down Expand Up @@ -299,4 +299,4 @@ Fetchers can be submitted programmatically with `fetcher.submit`:
</fetcher.Form>
```

Note the input event's form is passed as the first argument to `fetcher.submit`. The fetcher will use that form to submit the request, reading it's attributes and serializing the data from its elements.
Note the input event's form is passed as the first argument to `fetcher.submit`. The fetcher will use that form to submit the request, reading its attributes and serializing the data from its elements.
16 changes: 8 additions & 8 deletions docs/how-to/file-uploads.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ title: File Uploads

Handle file uploads in your React Router applications. This guide uses some packages from the [Remix The Web][remix-the-web] project to make file uploads easier.

_Thank you to David Adams for [writing an original guide](https://programmingarehard.com/2024/09/06/remix-file-uploads-updated.html/) which this doc is based on. You can refer to it for even more examples._
_Thank you to David Adams for [writing an original guide](https://programmingarehard.com/2024/09/06/remix-file-uploads-updated.html/) on which this doc is based. You can refer to it for even more examples._

## Basic File Upload

πŸ‘‰ **Setup some routes**
### 1. Setup some routes

You can setup your routes however you like. This example uses the following structure:

Expand All @@ -28,7 +28,7 @@ export default [
] satisfies RouteConfig;
```

πŸ‘‰ **Add the form data parser**
### 2. Add the form data parser

`form-data-parser` is a wrapper around `request.formData()` that provides streaming support for handling file uploads.

Expand All @@ -38,7 +38,7 @@ npm i @mjackson/form-data-parser

[See the `form-data-parser` docs for more information][form-data-parser]

πŸ‘‰ **Create a route with an upload action**
### 3. Create a route with an upload action

The `parseFormData` function takes an `uploadHandler` function as an argument. This function will be called for each file upload in the form.

Expand Down Expand Up @@ -83,7 +83,7 @@ export default function Component() {

## Local Storage Implementation

πŸ‘‰ **Add the storage package**
### 1. Add the storage package

`file-storage` is a key/value interface for storing [File objects][file] in JavaScript. Similar to how `localStorage` allows you to store key/value pairs of strings in the browser, file-storage allows you to store key/value pairs of files on the server.

Expand All @@ -93,7 +93,7 @@ npm i @mjackson/file-storage

[See the `file-storage` docs for more information][file-storage]

πŸ‘‰ **Create a storage configuration**
### 2. Create a storage configuration

Create a file that exports a `LocalFileStorage` instance to be used by different routes.

Expand All @@ -109,7 +109,7 @@ export function getStorageKey(userId: string) {
}
```

πŸ‘‰ **Implement the upload handler**
### 3. Implement the upload handler

Update the form's `action` to store files in the `fileStorage` instance.

Expand Down Expand Up @@ -177,7 +177,7 @@ export default function UserPage({
}
```

πŸ‘‰ **Add a route to serve the uploaded file**
### 4. Add a route to serve the uploaded file

Create a [resource route][resource-route] that streams the file as a response.

Expand Down
2 changes: 1 addition & 1 deletion docs/how-to/headers.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export async function loader({ params }: LoaderArgs) {

return data(page, {
headers: {
"Server-Timing': `page;dur=${ms};desc=`Page query"',
"Server-Timing": `page;dur=${ms};desc="Page query"`,
},
});
}
Expand Down
2 changes: 1 addition & 1 deletion docs/how-to/pre-rendering.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Pre-Rendering

# Pre-Rendering

Pre-rendering allows you to render a pages at build time instead of on a server to speed up pages loads for static content.
Pre-rendering allows you to render pages at build time instead of on a server to speed up pages loads for static content.

## Configuration

Expand Down
2 changes: 1 addition & 1 deletion docs/how-to/suspense.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Streaming with Suspense

# Streaming with Suspense

Streaming with React Suspense allows apps to speed up initial renders by unblocking initial UI by deferring non-critical data.
Streaming with React Suspense allows apps to speed up initial renders by deferring non-critical data and unblocking UI rendering.

React Router supports React Suspense by returning promises from loaders and actions.

Expand Down
14 changes: 7 additions & 7 deletions docs/how-to/view-transitions.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Enable smooth animations between page transitions in your React Router applicati

## Basic View Transition

πŸ‘‰ **Enable view transitions on navigation**
### 1. Enable view transitions on navigation

The simplest way to enable view transitions is by adding the `viewTransition` prop to your `Link`, `NavLink`, or `Form` components. This automatically wraps the navigation update in `document.startViewTransition()`.

Expand All @@ -26,7 +26,7 @@ For more information on using the View Transitions API, please refer to the ["Sm

Let's build an image gallery that demonstrates how to trigger and use view transitions. We'll create a list of images that expand into a detail view with smooth animations.

πŸ‘‰ **Create the image gallery route**
### 2. Create the image gallery route

```tsx filename=routes/image-gallery.tsx
import { NavLink } from "react-router";
Expand Down Expand Up @@ -62,7 +62,7 @@ export default function ImageGalleryRoute() {
}
```

πŸ‘‰ **Add transition styles**
### 3. Add transition styles

Define view transition names and animations for elements that should transition smoothly between routes.

Expand Down Expand Up @@ -98,7 +98,7 @@ Define view transition names and animations for elements that should transition
}
```

πŸ‘‰ **Create the image detail route**
### 4. Create the image detail route

The detail view needs to use the same view transition names to create a seamless animation.

Expand All @@ -122,7 +122,7 @@ export default function ImageDetailsRoute({
}
```

πŸ‘‰ **Add matching transition styles for the detail view**
### 5. Add matching transition styles for the detail view

```css filename=app.css
/* Match transition names from the list view */
Expand All @@ -144,7 +144,7 @@ export default function ImageDetailsRoute({

You can control view transitions more precisely using either render props or the `useViewTransitionState` hook.

πŸ‘‰ **Using render props**
### 1. Using render props

```tsx filename=routes/image-gallery.tsx
<NavLink to={`/image/${idx}`} viewTransition>
Expand Down Expand Up @@ -172,7 +172,7 @@ You can control view transitions more precisely using either render props or the
</NavLink>
```

πŸ‘‰ **Using the `useViewTransitionState` hook**
### 2. Using the `useViewTransitionState` hook

```tsx filename=routes/image-gallery.tsx
function NavImage(props: { src: string; idx: number }) {
Expand Down
4 changes: 2 additions & 2 deletions docs/start/framework/rendering.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ There are three rendering strategies in React Router:

## Client Side Rendering

All routes are always client side rendered as the user navigates around the app. If you're looking to build a Single Page App, disable server rendering:
Routes are always client side rendered as the user navigates around the app. If you're looking to build a Single Page App, disable server rendering:

```ts filename=react-router.config.ts
import type { Config } from "@react-router/dev/config";
Expand All @@ -33,7 +33,7 @@ export default {
} satisfies Config;
```

Server side rendering requires a deployment that supports it. Though it's a global setting, individual routes can still be statically pre-rendered, and/or use client data loading with `clientLoader` to avoid server rendering/fetching of their portion of the UI.
Server side rendering requires a deployment that supports it. Though it's a global setting, individual routes can still be statically pre-rendered. Routes can also use client data loading with `clientLoader` to avoid server rendering/fetching for their portion of the UI.

## Static Pre-rendering

Expand Down
2 changes: 1 addition & 1 deletion docs/start/framework/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ order: 2

## Configuring Routes

Routes are configured in `app/routes.ts`. Routes have a url pattern to match the URL and a file path to the route module to define its behavior.
Routes are configured in `app/routes.ts`. Each route has two required parts: a URL pattern to match the URL, and a file path to the route module that defines its behavior.

```ts filename=app/routes.ts
import {
Expand Down
4 changes: 2 additions & 2 deletions docs/upgrading/component-routes.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The Vite plugin adds:
- Optional Static pre-rendering
- Optional Server rendering

The initial setup will require the most work, but once complete, adopting the new features is incremental, you can do one route at a time.
The initial setup requires the most work. However, once complete, you can adopt new features incrementally, one route at a time.

## Prerequisites

Expand All @@ -40,7 +40,7 @@ npm install -D @react-router/dev

**πŸ‘‰ Install a runtime adapter**

We will assume you are using Node as your runtime
We will assume you are using Node as your runtime.

```shellscript nonumber
npm install @react-router/node
Expand Down
6 changes: 3 additions & 3 deletions docs/upgrading/remix.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ order: 2

# Upgrading from Remix

React Router v7 is the next major version of Remix after v2 (see our ["Incremental Path to React 19" blog post][incremental-path-to-react-19]) for more information).
React Router v7 is the next major version of Remix after v2 (see our ["Incremental Path to React 19" blog post][incremental-path-to-react-19] for more information).

The Remix v2 -> React Router v7 upgrade requires mostly updates to dependencies if you are caught up on all [Remix v2 future flags][v2-future-flags] (step 1).
If you have enabled all [Remix v2 future flags][v2-future-flags], upgrading from Remix v2 to React Router v7 mainly involves updating dependencies.

<docs-info>

Expand Down Expand Up @@ -239,7 +239,7 @@ export default defineConfig({

<docs-info>

If you're not using TypeScript, you can skip this step.
If you are not using TypeScript, you can skip this step.

</docs-info>

Expand Down
4 changes: 2 additions & 2 deletions docs/upgrading/router-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The Vite plugin adds:
- Optional Static pre-rendering
- Optional Server rendering

The initial setup will require the most work, but once complete, adopting the new features is incremental, you can do one route at a time.
The initial setup requires the most work. However, once complete, you can adopt new features incrementally, one route at a time.

## Prerequisites

Expand All @@ -48,7 +48,7 @@ npm install -D @react-router/dev

**πŸ‘‰ Install a runtime adapter**

We will assume you are using Node as your runtime
We will assume you are using Node as your runtime.

```shellscript nonumber
npm install @react-router/node
Expand Down
6 changes: 3 additions & 3 deletions docs/upgrading/v6.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ order: 1

# Upgrading from v6

The v7 upgrade is non-breaking if you are caught up on all future flags. These flags allow you to update your app one change at a time. We highly recommend you make a commit after each step and ship it instead of doing everything all at once.
The v7 upgrade has no breaking changes if you have enabled all future flags. These flags allow you to update your app one change at a time. We highly recommend you make a commit after each step and ship it instead of doing everything all at once.

## Update to latest v6.x

Expand Down Expand Up @@ -303,7 +303,7 @@ Now that your app is caught up, you can simply update to v7 (theoretically!) wit
npm install react-router-dom@latest
```

πŸ‘‰ **Uninstall react-router-dom, install react-router**
πŸ‘‰ **Replace react-router-dom with react-router**

In v7 we no longer need `"react-router-dom"` as the packages have been simplified. You can import everything from `"react-router"`:

Expand All @@ -316,7 +316,7 @@ Note you only need `"react-router"` in your package.json.

πŸ‘‰ **Update imports**

Now you can update you imports to use `react-router`:
Now you should update your imports to use `react-router`:

```diff
-import { useLocation } from "react-router-dom";
Expand Down

0 comments on commit 3f102fc

Please sign in to comment.