Skip to content

Commit bc6f8d0

Browse files
committed
docs: capitalize Context as a React concept (remaining files)
1 parent a983b33 commit bc6f8d0

11 files changed

Lines changed: 33 additions & 33 deletions

File tree

src/content/learn/managing-state.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -697,11 +697,11 @@ Read **[Extracting State Logic into a Reducer](/learn/extracting-state-logic-int
697697
698698
</LearnMore>
699699
700-
## Passing data deeply with context {/*passing-data-deeply-with-context*/}
700+
## Passing data deeply with Context {/*passing-data-deeply-with-context*/}
701701
702702
Usually, you will pass information from a parent component to a child component via props. But passing props can become inconvenient if you need to pass some prop through many components, or if many components need the same information. Context lets the parent component make some information available to any component in the tree below it—no matter how deep it is—without passing it explicitly through props.
703703
704-
Here, the `Heading` component determines its heading level by "asking" the closest `Section` for its level. Each `Section` tracks its own level by asking the parent `Section` and adding one to it. Every `Section` provides information to all components below it without passing props--it does that through context.
704+
Here, the `Heading` component determines its heading level by "asking" the closest `Section` for its level. Each `Section` tracks its own level by asking the parent `Section` and adding one to it. Every `Section` provides information to all components below it without passing props--it does that through Context.
705705
706706
<Sandpack>
707707
@@ -795,15 +795,15 @@ export const LevelContext = createContext(0);
795795
796796
<LearnMore path="/learn/passing-data-deeply-with-context">
797797
798-
Read **[Passing Data Deeply with Context](/learn/passing-data-deeply-with-context)** to learn about using context as an alternative to passing props.
798+
Read **[Passing Data Deeply with Context](/learn/passing-data-deeply-with-context)** to learn about using Context as an alternative to passing props.
799799
800800
</LearnMore>
801801
802-
## Scaling up with reducer and context {/*scaling-up-with-reducer-and-context*/}
802+
## Scaling up with reducer and Context {/*scaling-up-with-reducer-and-context*/}
803803
804-
Reducers let you consolidate a component’s state update logic. Context lets you pass information deep down to other components. You can combine reducers and context together to manage state of a complex screen.
804+
Reducers let you consolidate a component’s state update logic. Context lets you pass information deep down to other components. You can combine reducers and Context together to manage state of a complex screen.
805805
806-
With this approach, a parent component with complex state manages it with a reducer. Other components anywhere deep in the tree can read its state via context. They can also dispatch actions to update that state.
806+
With this approach, a parent component with complex state manages it with a reducer. Other components anywhere deep in the tree can read its state via Context. They can also dispatch actions to update that state.
807807
808808
<Sandpack>
809809

src/content/reference/eslint-plugin-react-hooks/lints/globals.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function Component() {
6767
);
6868
}
6969

70-
// ✅ Use context for global values
70+
// ✅ Use Context for global values
7171
function Component() {
7272
const user = useContext(UserContext);
7373
return <div>User: {user.id}</div>;

src/content/reference/react-dom/createPortal.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import { createPortal } from 'react-dom';
4242
4343
[See more examples below.](#usage)
4444
45-
A portal only changes the physical placement of the DOM node. In every other way, the JSX you render into a portal acts as a child node of the React component that renders it. For example, the child can access the context provided by the parent tree, and events bubble up from children to parents according to the React tree.
45+
A portal only changes the physical placement of the DOM node. In every other way, the JSX you render into a portal acts as a child node of the React component that renders it. For example, the child can access the Context provided by the parent tree, and events bubble up from children to parents according to the React tree.
4646
4747
#### Parameters {/*parameters*/}
4848
@@ -125,7 +125,7 @@ Notice how the second paragraph visually appears outside the parent `<div>` with
125125
</body>
126126
```
127127
128-
A portal only changes the physical placement of the DOM node. In every other way, the JSX you render into a portal acts as a child node of the React component that renders it. For example, the child can access the context provided by the parent tree, and events still bubble up from children to parents according to the React tree.
128+
A portal only changes the physical placement of the DOM node. In every other way, the JSX you render into a portal acts as a child node of the React component that renders it. For example, the child can access the Context provided by the parent tree, and events still bubble up from children to parents according to the React tree.
129129
130130
---
131131

src/content/reference/react/Component.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ Only the `render` method is required, other methods are optional.
5050

5151
### `context` {/*context*/}
5252

53-
The [context](/learn/passing-data-deeply-with-context) of a class component is available as `this.context`. It is only available if you specify *which* context you want to receive using [`static contextType`](#static-contexttype).
53+
The [Context](/learn/passing-data-deeply-with-context) of a class component is available as `this.context`. It is only available if you specify *which* Context you want to receive using [`static contextType`](#static-contexttype).
5454

55-
A class component can only read one context at a time.
55+
A class component can only read one Context at a time.
5656

5757
```js {2,5}
5858
class Button extends Component {
@@ -565,7 +565,7 @@ class Greeting extends Component {
565565
566566
React may call `render` at any moment, so you shouldn't assume that it runs at a particular time. Usually, the `render` method should return a piece of [JSX](/learn/writing-markup-with-jsx), but a few [other return types](#render-returns) (like strings) are supported. To calculate the returned JSX, the `render` method can read [`this.props`](#props), [`this.state`](#state), and [`this.context`](#context).
567567
568-
You should write the `render` method as a pure function, meaning that it should return the same result if props, state, and context are the same. It also shouldn't contain side effects (like setting up subscriptions) or interact with the browser APIs. Side effects should happen either in event handlers or methods like [`componentDidMount`.](#componentdidmount)
568+
You should write the `render` method as a pure function, meaning that it should return the same result if props, state, and Context are the same. It also shouldn't contain side effects (like setting up subscriptions) or interact with the browser APIs. Side effects should happen either in event handlers or methods like [`componentDidMount`.](#componentdidmount)
569569
570570
#### Parameters {/*render-parameters*/}
571571
@@ -714,7 +714,7 @@ React calls `shouldComponentUpdate` before rendering when new props or state are
714714
715715
- `nextProps`: The next props that the component is about to render with. Compare `nextProps` to [`this.props`](#props) to determine what changed.
716716
- `nextState`: The next state that the component is about to render with. Compare `nextState` to [`this.state`](#props) to determine what changed.
717-
- `nextContext`: The next context that the component is about to render with. Compare `nextContext` to [`this.context`](#context) to determine what changed. Only available if you specify [`static contextType`](#static-contexttype).
717+
- `nextContext`: The next Context that the component is about to render with. Compare `nextContext` to [`this.context`](#context) to determine what changed. Only available if you specify [`static contextType`](#static-contexttype).
718718
719719
#### Returns {/*shouldcomponentupdate-returns*/}
720720
@@ -789,7 +789,7 @@ If you define `UNSAFE_componentWillReceiveProps`, React will call it when the co
789789
#### Parameters {/*unsafe_componentwillreceiveprops-parameters*/}
790790
791791
- `nextProps`: The next props that the component is about to receive from its parent component. Compare `nextProps` to [`this.props`](#props) to determine what changed.
792-
- `nextContext`: The next context that the component is about to receive from the closest provider. Compare `nextContext` to [`this.context`](#context) to determine what changed. Only available if you specify [`static contextType`](#static-contexttype).
792+
- `nextContext`: The next Context that the component is about to receive from the closest provider. Compare `nextContext` to [`this.context`](#context) to determine what changed. Only available if you specify [`static contextType`](#static-contexttype).
793793
794794
#### Returns {/*unsafe_componentwillreceiveprops-returns*/}
795795
@@ -856,7 +856,7 @@ There is no direct equivalent to `UNSAFE_componentWillUpdate` in function compon
856856

857857
### `static contextType` {/*static-contexttype*/}
858858

859-
If you want to read [`this.context`](#context-instance-field) from your class component, you must specify which context it needs to read. The context you specify as the `static contextType` must be a value previously created by [`createContext`.](/reference/react/createContext)
859+
If you want to read [`this.context`](#context-instance-field) from your class component, you must specify which Context it needs to read. The Context you specify as the `static contextType` must be a value previously created by [`createContext`.](/reference/react/createContext)
860860

861861
```js {2}
862862
class Button extends Component {
@@ -1773,9 +1773,9 @@ If your component does not synchronize with any external systems, [you might not
17731773
17741774
---
17751775
1776-
### Migrating a component with context from a class to a function {/*migrating-a-component-with-context-from-a-class-to-a-function*/}
1776+
### Migrating a component with Context from a class to a function {/*migrating-a-component-with-context-from-a-class-to-a-function*/}
17771777
1778-
In this example, the `Panel` and `Button` class components read [context](/learn/passing-data-deeply-with-context) from [`this.context`:](#context)
1778+
In this example, the `Panel` and `Button` class components read [Context](/learn/passing-data-deeply-with-context) from [`this.context`:](#context)
17791779
17801780
<Sandpack>
17811781

src/content/reference/react/apis.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ In addition to [Hooks](/reference/react/hooks) and [Components](/reference/react
1010

1111
---
1212

13-
* [`createContext`](/reference/react/createContext) lets you define and provide context to the child components. Used with [`useContext`.](/reference/react/useContext)
13+
* [`createContext`](/reference/react/createContext) lets you define and provide Context to the child components. Used with [`useContext`.](/reference/react/useContext)
1414
* [`lazy`](/reference/react/lazy) lets you defer loading a component's code until it's rendered for the first time.
1515
* [`memo`](/reference/react/memo) lets your component skip re-renders with same props. Used with [`useMemo`](/reference/react/useMemo) and [`useCallback`.](/reference/react/useCallback)
1616
* [`startTransition`](/reference/react/startTransition) lets you mark a state update as non-urgent. Similar to [`useTransition`.](/reference/react/useTransition)
@@ -20,11 +20,11 @@ In addition to [Hooks](/reference/react/hooks) and [Components](/reference/react
2020

2121
## Resource APIs {/*resource-apis*/}
2222

23-
*Resources* can be accessed by a component without having them as part of their state. For example, a component can read a message from a Promise or read styling information from a context.
23+
*Resources* can be accessed by a component without having them as part of their state. For example, a component can read a message from a Promise or read styling information from a Context.
2424

2525
To read a value from a resource, use this API:
2626

27-
* [`use`](/reference/react/use) lets you read the value of a resource like a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) or [context](/learn/passing-data-deeply-with-context).
27+
* [`use`](/reference/react/use) lets you read the value of a resource like a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) or [Context](/learn/passing-data-deeply-with-context).
2828
```js
2929
function MessageComponent({ messagePromise }) {
3030
const message = use(messagePromise);

src/content/reference/react/use.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: use
44

55
<Intro>
66

7-
`use` is a React API that lets you read the value of a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) or [context](/learn/passing-data-deeply-with-context).
7+
`use` is a React API that lets you read the value of a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) or [Context](/learn/passing-data-deeply-with-context).
88

99
```js
1010
const value = use(resource);
@@ -20,7 +20,7 @@ const value = use(resource);
2020

2121
### `use(context)` {/*use-context*/}
2222

23-
Call `use` with a [context](/learn/passing-data-deeply-with-context) to read its value. Unlike [`useContext`](/reference/react/useContext), `use` can be called within loops and conditional statements like `if`.
23+
Call `use` with a [Context](/learn/passing-data-deeply-with-context) to read its value. Unlike [`useContext`](/reference/react/useContext), `use` can be called within loops and conditional statements like `if`.
2424

2525
```js
2626
import { use } from 'react';

src/content/reference/react/useContext.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: useContext
44

55
<Intro>
66

7-
`useContext` is a React Hook that lets you read and subscribe to [context](/learn/passing-data-deeply-with-context) from your component.
7+
`useContext` is a React Hook that lets you read and subscribe to [Context](/learn/passing-data-deeply-with-context) from your component.
88

99
```js
1010
const value = useContext(SomeContext)
@@ -20,7 +20,7 @@ const value = useContext(SomeContext)
2020

2121
### `useContext(SomeContext)` {/*usecontext*/}
2222

23-
Call `useContext` at the top level of your component to read and subscribe to [context.](/learn/passing-data-deeply-with-context)
23+
Call `useContext` at the top level of your component to read and subscribe to [Context.](/learn/passing-data-deeply-with-context)
2424

2525
```js
2626
import { useContext } from 'react';
@@ -53,7 +53,7 @@ function MyComponent() {
5353
5454
### Passing data deeply into the tree {/*passing-data-deeply-into-the-tree*/}
5555
56-
Call `useContext` at the top level of your component to read and subscribe to [context.](/learn/passing-data-deeply-with-context)
56+
Call `useContext` at the top level of your component to read and subscribe to [Context.](/learn/passing-data-deeply-with-context)
5757
5858
```js [[2, 4, "theme"], [1, 4, "ThemeContext"]]
5959
import { useContext } from 'react';
@@ -197,7 +197,7 @@ function MyPage() {
197197
198198
Now any `Button` inside of the provider will receive the current `theme` value. If you call `setTheme` to update the `theme` value that you pass to the provider, all `Button` components will re-render with the new `'light'` value.
199199
200-
<Recipes titleText="Examples of updating context" titleId="examples-basic">
200+
<Recipes titleText="Examples of updating Context" titleId="examples-basic">
201201
202202
#### Updating a value via Context {/*updating-a-value-via-context*/}
203203
@@ -1290,7 +1290,7 @@ export const LevelContext = createContext(0);
12901290
12911291
### Optimizing re-renders when passing objects and functions {/*optimizing-re-renders-when-passing-objects-and-functions*/}
12921292
1293-
You can pass any values via context, including objects and functions.
1293+
You can pass any values via Context, including objects and functions.
12941294
12951295
```js [[2, 10, "{ currentUser, login }"]]
12961296
function MyApp() {
@@ -1309,7 +1309,7 @@ function MyApp() {
13091309
}
13101310
```
13111311
1312-
Here, the <CodeStep step={2}>context value</CodeStep> is a JavaScript object with two properties, one of which is a function. Whenever `MyApp` re-renders (for example, on a route update), this will be a *different* object pointing at a *different* function, so React will also have to re-render all components deep in the tree that call `useContext(AuthContext)`.
1312+
Here, the <CodeStep step={2}>Context value</CodeStep> is a JavaScript object with two properties, one of which is a function. Whenever `MyApp` re-renders (for example, on a route update), this will be a *different* object pointing at a *different* function, so React will also have to re-render all components deep in the tree that call `useContext(AuthContext)`.
13131313
13141314
In smaller apps, this is not a problem. However, there is no need to re-render them if the underlying data, like `currentUser`, has not changed. To help React take advantage of that fact, you may wrap the `login` function with [`useCallback`](/reference/react/useCallback) and wrap the object creation into [`useMemo`](/reference/react/useMemo). This is a performance optimization:
13151315

src/content/reference/react/useRef.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export default function Stopwatch() {
192192
193193
React expects that the body of your component [behaves like a pure function](/learn/keeping-components-pure):
194194
195-
- If the inputs ([props](/learn/passing-props-to-a-component), [state](/learn/state-a-components-memory), and [context](/learn/passing-data-deeply-with-context)) are the same, it should return exactly the same JSX.
195+
- If the inputs ([props](/learn/passing-props-to-a-component), [state](/learn/state-a-components-memory), and [Context](/learn/passing-data-deeply-with-context)) are the same, it should return exactly the same JSX.
196196
- Calling it in a different order or with different arguments should not affect the results of other calls.
197197
198198
Reading or writing a ref **during rendering** breaks these expectations.

src/content/reference/react/useSyncExternalStore.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ The current snapshot of the store which you can use in your rendering logic.
8383
8484
### Subscribing to an external store {/*subscribing-to-an-external-store*/}
8585
86-
Most of your React components will only read data from their [props,](/learn/passing-props-to-a-component) [state,](/reference/react/useState) and [context.](/reference/react/useContext) However, sometimes a component needs to read some data from some store outside of React that changes over time. This includes:
86+
Most of your React components will only read data from their [props,](/learn/passing-props-to-a-component) [state,](/reference/react/useState) and [Context.](/reference/react/useContext) However, sometimes a component needs to read some data from some store outside of React that changes over time. This includes:
8787
8888
* Third-party state management libraries that hold state outside of React.
8989
* Browser APIs that expose a mutable value and events to subscribe to its changes.

src/content/reference/rules/components-and-hooks-must-be-pure.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This reference page covers advanced topics and requires familiarity with the con
1616

1717
One of the key concepts that makes React, _React_ is _purity_. A pure component or hook is one that is:
1818

19-
* **Idempotent** – You [always get the same result every time](/learn/keeping-components-pure#purity-components-as-formulas) you run it with the same inputs – props, state, context for component inputs; and arguments for hook inputs.
19+
* **Idempotent** – You [always get the same result every time](/learn/keeping-components-pure#purity-components-as-formulas) you run it with the same inputs – props, state, Context for component inputs; and arguments for hook inputs.
2020
* **Has no side effects in render** – Code with side effects should run [**separately from rendering**](#how-does-react-run-your-code). For example as an [event handler](/learn/responding-to-events) – where the user interacts with the UI and causes it to update; or as an [Effect](/reference/react/useEffect) – which runs after render.
2121
* **Does not mutate non-local values**: Components and Hooks should [never modify values that aren't created locally](#mutation) in render.
2222

@@ -70,7 +70,7 @@ function Dropdown() {
7070

7171
## Components and Hooks must be idempotent {/*components-and-hooks-must-be-idempotent*/}
7272

73-
Components must always return the same output with respect to their inputs – props, state, and context. This is known as _idempotency_. [Idempotency](https://en.wikipedia.org/wiki/Idempotence) is a term popularized in functional programming. It refers to the idea that you [always get the same result every time](learn/keeping-components-pure) you run that piece of code with the same inputs.
73+
Components must always return the same output with respect to their inputs – props, state, and Context. This is known as _idempotency_. [Idempotency](https://en.wikipedia.org/wiki/Idempotence) is a term popularized in functional programming. It refers to the idea that you [always get the same result every time](learn/keeping-components-pure) you run that piece of code with the same inputs.
7474

7575
This means that _all_ code that runs [during render](#how-does-react-run-your-code) must also be idempotent in order for this rule to hold. For example, this line of code is not idempotent (and therefore, neither is the component):
7676

0 commit comments

Comments
 (0)