From 5f2b3992c35ba7e43a046faacd0680c514b0e8c6 Mon Sep 17 00:00:00 2001
From: Anthony Laflamme
Date: Wed, 27 Mar 2024 07:24:22 -0400
Subject: [PATCH 1/9] fix: Fix capitalization of word Component/s
---
README.md | 2 +-
src/components/Layout/HomeContent.js | 20 +-
src/components/Seo.tsx | 2 +-
.../blog/2021/06/08/the-plan-for-react-18.md | 4 +-
.../blog/2021/12/17/react-conf-2021-recap.md | 2 +-
.../blog/2022/03/08/react-18-upgrade-guide.md | 22 +--
src/content/blog/2022/03/29/react-v18.md | 26 +--
...-what-we-have-been-working-on-june-2022.md | 6 +-
.../blog/2023/03/16/introducing-react-dev.md | 14 +-
...what-we-have-been-working-on-march-2023.md | 24 +--
...t-we-have-been-working-on-february-2024.md | 8 +-
src/content/community/team.md | 2 +-
src/content/community/versioning-policy.md | 4 +-
src/content/community/videos.md | 2 +-
.../learn/add-react-to-an-existing-project.md | 20 +-
src/content/learn/adding-interactivity.md | 16 +-
.../learn/choosing-the-state-structure.md | 16 +-
src/content/learn/conditional-rendering.md | 16 +-
src/content/learn/describing-the-ui.md | 38 ++--
src/content/learn/escape-hatches.md | 18 +-
.../extracting-state-logic-into-a-reducer.md | 16 +-
.../importing-and-exporting-components.md | 54 +++---
src/content/learn/index.md | 34 ++--
.../javascript-in-jsx-with-curly-braces.md | 2 +-
src/content/learn/keeping-components-pure.md | 58 +++---
.../learn/lifecycle-of-reactive-effects.md | 60 +++---
src/content/learn/managing-state.md | 26 +--
.../learn/manipulating-the-dom-with-refs.md | 30 +--
.../learn/passing-data-deeply-with-context.md | 72 +++----
.../learn/passing-props-to-a-component.md | 46 ++---
.../learn/preserving-and-resetting-state.md | 78 ++++----
.../learn/reacting-to-input-with-state.md | 14 +-
.../learn/referencing-values-with-refs.md | 26 +--
.../learn/removing-effect-dependencies.md | 28 +--
src/content/learn/render-and-commit.md | 28 +--
src/content/learn/rendering-lists.md | 30 +--
src/content/learn/responding-to-events.md | 32 ++--
.../learn/reusing-logic-with-custom-hooks.md | 64 +++----
.../scaling-up-with-reducer-and-context.md | 40 ++--
.../learn/separating-events-from-effects.md | 22 +--
.../learn/sharing-state-between-components.md | 56 +++---
.../learn/start-a-new-react-project.md | 12 +-
.../learn/state-a-components-memory.md | 42 ++--
src/content/learn/state-as-a-snapshot.md | 10 +-
.../learn/synchronizing-with-effects.md | 84 ++++----
src/content/learn/thinking-in-react.md | 52 ++---
src/content/learn/tutorial-tic-tac-toe.md | 116 +++++------
src/content/learn/typescript.md | 8 +-
.../learn/understanding-your-ui-as-a-tree.md | 26 +--
.../learn/updating-objects-in-state.md | 4 +-
src/content/learn/writing-markup-with-jsx.md | 10 +-
.../learn/you-might-not-need-an-effect.md | 88 ++++-----
src/content/learn/your-first-component.md | 64 +++----
.../reference/react-dom/client/createRoot.md | 28 +--
.../reference/react-dom/client/hydrateRoot.md | 20 +-
.../reference/react-dom/client/index.md | 6 +-
.../reference/react-dom/components/common.md | 8 +-
.../reference/react-dom/components/form.md | 2 +-
.../reference/react-dom/components/index.md | 16 +-
.../reference/react-dom/components/input.md | 10 +-
.../reference/react-dom/components/link.md | 16 +-
.../reference/react-dom/components/meta.md | 12 +-
.../reference/react-dom/components/option.md | 2 +-
.../reference/react-dom/components/script.md | 12 +-
.../reference/react-dom/components/select.md | 4 +-
.../reference/react-dom/components/style.md | 10 +-
.../react-dom/components/textarea.md | 6 +-
.../reference/react-dom/components/title.md | 14 +-
.../reference/react-dom/createPortal.md | 12 +-
.../reference/react-dom/findDOMNode.md | 20 +-
.../reference/react-dom/hooks/useFormState.md | 10 +-
.../react-dom/hooks/useFormStatus.md | 14 +-
src/content/reference/react-dom/hydrate.md | 8 +-
src/content/reference/react-dom/index.md | 8 +-
src/content/reference/react-dom/preconnect.md | 4 +-
.../reference/react-dom/prefetchDNS.md | 4 +-
src/content/reference/react-dom/preinit.md | 4 +-
.../reference/react-dom/preinitModule.md | 4 +-
src/content/reference/react-dom/preload.md | 4 +-
.../reference/react-dom/preloadModule.md | 4 +-
src/content/reference/react-dom/render.md | 16 +-
.../reference/react-dom/server/index.md | 2 +-
.../server/renderToPipeableStream.md | 20 +-
.../server/renderToReadableStream.md | 20 +-
.../react-dom/server/renderToStaticMarkup.md | 4 +-
.../react-dom/server/renderToString.md | 10 +-
.../react-dom/unmountComponentAtNode.md | 8 +-
src/content/reference/react/Children.md | 26 +--
src/content/reference/react/Component.md | 180 +++++++++---------
src/content/reference/react/Fragment.md | 2 +-
src/content/reference/react/Profiler.md | 12 +-
src/content/reference/react/PureComponent.md | 22 +--
src/content/reference/react/StrictMode.md | 46 ++---
src/content/reference/react/Suspense.md | 56 +++---
src/content/reference/react/apis.md | 4 +-
src/content/reference/react/cache.md | 42 ++--
src/content/reference/react/cloneElement.md | 8 +-
src/content/reference/react/components.md | 8 +-
src/content/reference/react/createContext.md | 24 +--
src/content/reference/react/createElement.md | 8 +-
src/content/reference/react/createFactory.md | 2 +-
src/content/reference/react/createRef.md | 10 +-
src/content/reference/react/forwardRef.md | 42 ++--
src/content/reference/react/hooks.md | 16 +-
src/content/reference/react/index.md | 10 +-
src/content/reference/react/lazy.md | 18 +-
src/content/reference/react/legacy.md | 2 +-
src/content/reference/react/memo.md | 54 +++---
.../reference/react/startTransition.md | 2 +-
src/content/reference/react/use-client.md | 60 +++---
src/content/reference/react/use-server.md | 2 +-
src/content/reference/react/use.md | 26 +--
src/content/reference/react/useCallback.md | 40 ++--
src/content/reference/react/useContext.md | 42 ++--
src/content/reference/react/useDebugValue.md | 8 +-
.../reference/react/useDeferredValue.md | 22 +--
src/content/reference/react/useEffect.md | 56 +++---
src/content/reference/react/useId.md | 12 +-
.../reference/react/useImperativeHandle.md | 14 +-
.../reference/react/useInsertionEffect.md | 10 +-
.../reference/react/useLayoutEffect.md | 22 +--
src/content/reference/react/useMemo.md | 64 +++----
src/content/reference/react/useReducer.md | 20 +-
src/content/reference/react/useRef.md | 30 +--
src/content/reference/react/useState.md | 34 ++--
.../reference/react/useSyncExternalStore.md | 30 +--
src/content/reference/react/useTransition.md | 30 +--
.../components-and-hooks-must-be-pure.md | 36 ++--
src/content/reference/rules/index.md | 8 +-
.../rules/react-calls-components-and-hooks.md | 26 +--
src/content/reference/rules/rules-of-hooks.md | 8 +-
.../warnings/invalid-hook-call-warning.md | 8 +-
src/content/warnings/unknown-prop.md | 4 +-
133 files changed, 1571 insertions(+), 1571 deletions(-)
diff --git a/README.md b/README.md
index 966131db576..9b11287efd5 100644
--- a/README.md
+++ b/README.md
@@ -38,7 +38,7 @@ The documentation is divided into several sections with a different tone and pur
1. Follow the ["Running locally"](#running-locally) instructions
1. Save the files and check in the browser
- 1. Changes to React components in `src` will hot-reload
+ 1. Changes to React Components in `src` will hot-reload
1. Changes to markdown files in `content` will hot-reload
1. If working with plugins, you may need to remove the `.cache` directory and restart the server
diff --git a/src/components/Layout/HomeContent.js b/src/components/Layout/HomeContent.js
index e1fab6d713a..921ded9197d 100644
--- a/src/components/Layout/HomeContent.js
+++ b/src/components/Layout/HomeContent.js
@@ -151,7 +151,7 @@ export function HomeContent() {
Create user interfaces from components
React lets you build user interfaces out of individual pieces
- called components. Create your own React components like{' '}
+ called components. Create your own React Components like{' '}
Thumbnail, LikeButton, and{' '}
Video. Then combine them into entire screens, pages,
and apps.
@@ -164,7 +164,7 @@ export function HomeContent() {
Whether you work on your own or with thousands of other
developers, using React feels the same. It is designed to let you
- seamlessly combine components written by independent people,
+ seamlessly combine Components written by independent people,
teams, and organizations.
@@ -172,9 +172,9 @@ export function HomeContent() {
- Write components with code and markup
+ Write Components with code and markup
- React components are JavaScript functions. Want to show some
+ React Components are JavaScript functions. Want to show some
content conditionally? Use an if statement.
Displaying a list? Try array map(). Learning React is
learning programming.
@@ -187,7 +187,7 @@ export function HomeContent() {
This markup syntax is called JSX. It is a JavaScript syntax
extension popularized by React. Putting JSX markup close to
- related rendering logic makes React components easy to create,
+ related rendering logic makes React Components easy to create,
maintain, and delete.
@@ -197,7 +197,7 @@ export function HomeContent() {
Add interactivity wherever you need it
- React components receive data and return what should appear on the
+ React Components receive data and return what should appear on the
screen. You can pass them new data in response to an interaction,
like when the user types into an input. React will then update the
screen to match the new data.
@@ -230,7 +230,7 @@ export function HomeContent() {
with a framework
- React is a library. It lets you put components together, but it
+ React is a library. It lets you put Components together, but it
doesn’t prescribe how to do routing and data fetching. To build an
entire app with React, we recommend a full-stack React framework
like Next.js or{' '}
@@ -243,7 +243,7 @@ export function HomeContent() {
React is also an architecture. Frameworks that implement it let
- you fetch data in asynchronous components that run on the server
+ you fetch data in asynchronous Components that run on the server
or even during the build. Read data from a file or a database, and
pass it down to your interactive components.
@@ -378,7 +378,7 @@ export function HomeContent() {
let you build apps in React for Android, iOS, and
more. They look and feel native because their UIs{' '}
are truly native. It’s not a web view—your
- React components render real Android and iOS views
+ React Components render real Android and iOS views
provided by the platform.
@@ -411,7 +411,7 @@ export function HomeContent() {
React approaches changes with care. Every React commit is
tested on business-critical surfaces with over a billion
- users. Over 100,000 React components at Meta help validate
+ users. Over 100,000 React Components at Meta help validate
every migration strategy.
diff --git a/src/components/Seo.tsx b/src/components/Seo.tsx
index dfc4f61049d..210a67603b5 100644
--- a/src/components/Seo.tsx
+++ b/src/components/Seo.tsx
@@ -55,7 +55,7 @@ export const Seo = withRouter(
// Twitter's meta parser is not very good.
const twitterTitle = pageTitle.replace(/[<>]/g, '');
let description = isHomePage
- ? 'React is the library for web and native user interfaces. Build user interfaces out of individual pieces called components written in JavaScript. React is designed to let you seamlessly combine components written by independent people, teams, and organizations.'
+ ? 'React is the library for web and native user interfaces. Build user interfaces out of individual pieces called Components written in JavaScript. React is designed to let you seamlessly combine Components written by independent people, teams, and organizations.'
: 'The library for web and native user interfaces';
return (
diff --git a/src/content/blog/2021/06/08/the-plan-for-react-18.md b/src/content/blog/2021/06/08/the-plan-for-react-18.md
index 0bf744c1ddb..42c0d75d6a0 100644
--- a/src/content/blog/2021/06/08/the-plan-for-react-18.md
+++ b/src/content/blog/2021/06/08/the-plan-for-react-18.md
@@ -30,9 +30,9 @@ If you've been following our research into the future of React (we don't expect
## A gradual adoption strategy {/*a-gradual-adoption-strategy*/}
-Since concurrency in React 18 is opt-in, there are no significant out-of-the-box breaking changes to component behavior. **You can upgrade to React 18 with minimal or no changes to your application code, with a level of effort comparable to a typical major React release**. Based on our experience converting several apps to React 18, we expect that many users will be able to upgrade within a single afternoon.
+Since concurrency in React 18 is opt-in, there are no significant out-of-the-box breaking changes to Component behavior. **You can upgrade to React 18 with minimal or no changes to your application code, with a level of effort comparable to a typical major React release**. Based on our experience converting several apps to React 18, we expect that many users will be able to upgrade within a single afternoon.
-We successfully shipped concurrent features to tens of thousands of components at Facebook, and in our experience, we've found that most React components “just work” without additional changes. We're committed to making sure this is a smooth upgrade for the entire community, so today we're announcing the React 18 Working Group.
+We successfully shipped concurrent features to tens of thousands of Components at Facebook, and in our experience, we've found that most React Components “just work” without additional changes. We're committed to making sure this is a smooth upgrade for the entire community, so today we're announcing the React 18 Working Group.
## Working with the community {/*working-with-the-community*/}
diff --git a/src/content/blog/2021/12/17/react-conf-2021-recap.md b/src/content/blog/2021/12/17/react-conf-2021-recap.md
index 89e407af3f0..3ce1ec4c7ce 100644
--- a/src/content/blog/2021/12/17/react-conf-2021-recap.md
+++ b/src/content/blog/2021/12/17/react-conf-2021-recap.md
@@ -65,7 +65,7 @@ For a demo of upgrading to React 18, see [Shruti Kapoor](https://twitter.com/shr
React 18 also includes improvements to server-side rendering performance using Suspense.
-Streaming server rendering lets you generate HTML from React components on the server, and stream that HTML to your users. In React 18, you can use `Suspense` to break down your app into smaller independent units which can be streamed independently of each other without blocking the rest of the app. This means users will see your content sooner and be able to start interacting with it much faster.
+Streaming server rendering lets you generate HTML from React Components on the server, and stream that HTML to your users. In React 18, you can use `Suspense` to break down your app into smaller independent units which can be streamed independently of each other without blocking the rest of the app. This means users will see your content sooner and be able to start interacting with it much faster.
For a deep dive, see [Shaundai Person](https://twitter.com/shaundai)’s talk here:
diff --git a/src/content/blog/2022/03/08/react-18-upgrade-guide.md b/src/content/blog/2022/03/08/react-18-upgrade-guide.md
index 66da896ec4a..18f3cf570bd 100644
--- a/src/content/blog/2022/03/08/react-18-upgrade-guide.md
+++ b/src/content/blog/2022/03/08/react-18-upgrade-guide.md
@@ -119,7 +119,7 @@ For more information, see the [working group discussion here](https://github.com
-**If your app doesn't work after upgrading, check whether it's wrapped in ``.** [Strict Mode has gotten stricter in React 18](#updates-to-strict-mode), and not all your components may be resilient to the new checks it adds in development mode. If removing Strict Mode fixes your app, you can remove it during the upgrade, and then add it back (either at the top or for a part of the tree) after you fix the issues that it's pointing out.
+**If your app doesn't work after upgrading, check whether it's wrapped in ``.** [Strict Mode has gotten stricter in React 18](#updates-to-strict-mode), and not all your Components may be resilient to the new checks it adds in development mode. If removing Strict Mode fixes your app, you can remove it during the upgrade, and then add it back (either at the top or for a part of the tree) after you fix the issues that it's pointing out.
@@ -231,13 +231,13 @@ React 18 also introduces new APIs for concurrent rendering such as `startTransit
## Updates to Strict Mode {/*updates-to-strict-mode*/}
-In the future, we'd like to add a feature that allows React to add and remove sections of the UI while preserving state. For example, when a user tabs away from a screen and back, React should be able to immediately show the previous screen. To do this, React would unmount and remount trees using the same component state as before.
+In the future, we'd like to add a feature that allows React to add and remove sections of the UI while preserving state. For example, when a user tabs away from a screen and back, React should be able to immediately show the previous screen. To do this, React would unmount and remount trees using the same Component state as before.
-This feature will give React better performance out-of-the-box, but requires components to be resilient to effects being mounted and destroyed multiple times. Most effects will work without any changes, but some effects assume they are only mounted or destroyed once.
+This feature will give React better performance out-of-the-box, but requires Components to be resilient to effects being mounted and destroyed multiple times. Most effects will work without any changes, but some effects assume they are only mounted or destroyed once.
-To help surface these issues, React 18 introduces a new development-only check to Strict Mode. This new check will automatically unmount and remount every component, whenever a component mounts for the first time, restoring the previous state on the second mount.
+To help surface these issues, React 18 introduces a new development-only check to Strict Mode. This new check will automatically unmount and remount every component, whenever a Component mounts for the first time, restoring the previous state on the second mount.
-Before this change, React would mount the component and create the effects:
+Before this change, React would mount the Component and create the effects:
```
* React mounts the component.
@@ -245,7 +245,7 @@ Before this change, React would mount the component and create the effects:
* Effect effects are created.
```
-With Strict Mode in React 18, React will simulate unmounting and remounting the component in development mode:
+With Strict Mode in React 18, React will simulate unmounting and remounting the Component in development mode:
```
* React mounts the component.
@@ -254,7 +254,7 @@ With Strict Mode in React 18, React will simulate unmounting and remounting the
* React simulates unmounting the component.
* Layout effects are destroyed.
* Effects are destroyed.
-* React simulates mounting the component with the previous state.
+* React simulates mounting the Component with the previous state.
* Layout effect setup code runs
* Effect setup code runs
```
@@ -304,18 +304,18 @@ If you need to support Internet Explorer we recommend you stay with React 17.
* **Consistent useEffect timing**: React now always synchronously flushes effect functions if the update was triggered during a discrete user input event such as a click or a keydown event. Previously, the behavior wasn't always predictable or consistent.
* **Stricter hydration errors**: Hydration mismatches due to missing or extra text content are now treated like errors instead of warnings. React will no longer attempt to "patch up" individual nodes by inserting or deleting a node on the client in an attempt to match the server markup, and will revert to client rendering up to the closest `` boundary in the tree. This ensures the hydrated tree is consistent and avoids potential privacy and security holes that can be caused by hydration mismatches.
-* **Suspense trees are always consistent:** If a component suspends before it's fully added to the tree, React will not add it to the tree in an incomplete state or fire its effects. Instead, React will throw away the new tree completely, wait for the asynchronous operation to finish, and then retry rendering again from scratch. React will render the retry attempt concurrently, and without blocking the browser.
-* **Layout Effects with Suspense**: When a tree re-suspends and reverts to a fallback, React will now clean up layout effects, and then re-create them when the content inside the boundary is shown again. This fixes an issue which prevented component libraries from correctly measuring layout when used with Suspense.
+* **Suspense trees are always consistent:** If a Component suspends before it's fully added to the tree, React will not add it to the tree in an incomplete state or fire its effects. Instead, React will throw away the new tree completely, wait for the asynchronous operation to finish, and then retry rendering again from scratch. React will render the retry attempt concurrently, and without blocking the browser.
+* **Layout Effects with Suspense**: When a tree re-suspends and reverts to a fallback, React will now clean up layout effects, and then re-create them when the content inside the boundary is shown again. This fixes an issue which prevented Component libraries from correctly measuring layout when used with Suspense.
* **New JS Environment Requirements**: React now depends on modern browsers features including `Promise`, `Symbol`, and `Object.assign`. If you support older browsers and devices such as Internet Explorer which do not provide modern browser features natively or have non-compliant implementations, consider including a global polyfill in your bundled application.
## Other Notable Changes {/*other-notable-changes*/}
### React {/*react*/}
-* **Components can now render `undefined`:** React no longer warns if you return `undefined` from a component. This makes the allowed component return values consistent with values that are allowed in the middle of a component tree. We suggest to use a linter to prevent mistakes like forgetting a `return` statement before JSX.
+* **Components can now render `undefined`:** React no longer warns if you return `undefined` from a component. This makes the allowed Component return values consistent with values that are allowed in the middle of a Component tree. We suggest to use a linter to prevent mistakes like forgetting a `return` statement before JSX.
* **In tests, `act` warnings are now opt-in:** If you're running end-to-end tests, the `act` warnings are unnecessary. We've introduced an [opt-in](https://github.com/reactwg/react-18/discussions/102) mechanism so you can enable them only for unit tests where they are useful and beneficial.
* **No warning about `setState` on unmounted components:** Previously, React warned about memory leaks when you call `setState` on an unmounted component. This warning was added for subscriptions, but people primarily run into it in scenarios where setting state is fine, and workarounds make the code worse. We've [removed](https://github.com/facebook/react/pull/22114) this warning.
-* **No suppression of console logs:** When you use Strict Mode, React renders each component twice to help you find unexpected side effects. In React 17, we've suppressed console logs for one of the two renders to make the logs easier to read. In response to [community feedback](https://github.com/facebook/react/issues/21783) about this being confusing, we've removed the suppression. Instead, if you have React DevTools installed, the second log's renders will be displayed in grey, and there will be an option (off by default) to suppress them completely.
+* **No suppression of console logs:** When you use Strict Mode, React renders each Component twice to help you find unexpected side effects. In React 17, we've suppressed console logs for one of the two renders to make the logs easier to read. In response to [community feedback](https://github.com/facebook/react/issues/21783) about this being confusing, we've removed the suppression. Instead, if you have React DevTools installed, the second log's renders will be displayed in grey, and there will be an option (off by default) to suppress them completely.
* **Improved memory usage:** React now cleans up more internal fields on unmount, making the impact from unfixed memory leaks that may exist in your application code less severe.
### React DOM Server {/*react-dom-server*/}
diff --git a/src/content/blog/2022/03/29/react-v18.md b/src/content/blog/2022/03/29/react-v18.md
index 743404c1af9..22b484960e9 100644
--- a/src/content/blog/2022/03/29/react-v18.md
+++ b/src/content/blog/2022/03/29/react-v18.md
@@ -48,15 +48,15 @@ A key property of Concurrent React is that rendering is interruptible. When you
In a concurrent render, this is not always the case. React may start rendering an update, pause in the middle, then continue later. It may even abandon an in-progress render altogether. React guarantees that the UI will appear consistent even if a render is interrupted. To do this, it waits to perform DOM mutations until the end, once the entire tree has been evaluated. With this capability, React can prepare new screens in the background without blocking the main thread. This means the UI can respond immediately to user input even if it’s in the middle of a large rendering task, creating a fluid user experience.
-Another example is reusable state. Concurrent React can remove sections of the UI from the screen, then add them back later while reusing the previous state. For example, when a user tabs away from a screen and back, React should be able to restore the previous screen in the same state it was in before. In an upcoming minor, we're planning to add a new component called `` that implements this pattern. Similarly, you’ll be able to use Offscreen to prepare new UI in the background so that it’s ready before the user reveals it.
+Another example is reusable state. Concurrent React can remove sections of the UI from the screen, then add them back later while reusing the previous state. For example, when a user tabs away from a screen and back, React should be able to restore the previous screen in the same state it was in before. In an upcoming minor, we're planning to add a new Component called `` that implements this pattern. Similarly, you’ll be able to use Offscreen to prepare new UI in the background so that it’s ready before the user reveals it.
Concurrent rendering is a powerful new tool in React and most of our new features are built to take advantage of it, including Suspense, transitions, and streaming server rendering. But React 18 is just the beginning of what we aim to build on this new foundation.
## Gradually Adopting Concurrent Features {/*gradually-adopting-concurrent-features*/}
-Technically, concurrent rendering is a breaking change. Because concurrent rendering is interruptible, components behave slightly differently when it is enabled.
+Technically, concurrent rendering is a breaking change. Because concurrent rendering is interruptible, Components behave slightly differently when it is enabled.
-In our testing, we've upgraded thousands of components to React 18. What we've found is that nearly all existing components "just work" with concurrent rendering, without any changes. However, some of them may require some additional migration effort. Although the changes are usually small, you'll still have the ability to make them at your own pace. The new rendering behavior in React 18 is **only enabled in the parts of your app that use new features.**
+In our testing, we've upgraded thousands of Components to React 18. What we've found is that nearly all existing Components "just work" with concurrent rendering, without any changes. However, some of them may require some additional migration effort. Although the changes are usually small, you'll still have the ability to make them at your own pace. The new rendering behavior in React 18 is **only enabled in the parts of your app that use new features.**
The overall upgrade strategy is to get your application running on React 18 without breaking existing code. Then you can gradually start adding concurrent features at your own pace. You can use [``](/reference/react/StrictMode) to help surface concurrency-related bugs during development. Strict Mode doesn't affect production behavior, but during development it will log extra warnings and double-invoke functions that are expected to be idempotent. It won't catch everything, but it's effective at preventing the most common types of mistakes.
@@ -148,7 +148,7 @@ Transitions will opt in to concurrent rendering, which allows the update to be i
### New Suspense Features {/*new-suspense-features*/}
-Suspense lets you declaratively specify the loading state for a part of the component tree if it's not yet ready to be displayed:
+Suspense lets you declaratively specify the loading state for a part of the Component tree if it's not yet ready to be displayed:
```js
}>
@@ -194,13 +194,13 @@ The existing `renderToString` method keeps working but is discouraged.
### New Strict Mode Behaviors {/*new-strict-mode-behaviors*/}
-In the future, we’d like to add a feature that allows React to add and remove sections of the UI while preserving state. For example, when a user tabs away from a screen and back, React should be able to immediately show the previous screen. To do this, React would unmount and remount trees using the same component state as before.
+In the future, we’d like to add a feature that allows React to add and remove sections of the UI while preserving state. For example, when a user tabs away from a screen and back, React should be able to immediately show the previous screen. To do this, React would unmount and remount trees using the same Component state as before.
-This feature will give React apps better performance out-of-the-box, but requires components to be resilient to effects being mounted and destroyed multiple times. Most effects will work without any changes, but some effects assume they are only mounted or destroyed once.
+This feature will give React apps better performance out-of-the-box, but requires Components to be resilient to effects being mounted and destroyed multiple times. Most effects will work without any changes, but some effects assume they are only mounted or destroyed once.
-To help surface these issues, React 18 introduces a new development-only check to Strict Mode. This new check will automatically unmount and remount every component, whenever a component mounts for the first time, restoring the previous state on the second mount.
+To help surface these issues, React 18 introduces a new development-only check to Strict Mode. This new check will automatically unmount and remount every component, whenever a Component mounts for the first time, restoring the previous state on the second mount.
-Before this change, React would mount the component and create the effects:
+Before this change, React would mount the Component and create the effects:
```
* React mounts the component.
@@ -209,7 +209,7 @@ Before this change, React would mount the component and create the effects:
```
-With Strict Mode in React 18, React will simulate unmounting and remounting the component in development mode:
+With Strict Mode in React 18, React will simulate unmounting and remounting the Component in development mode:
```
* React mounts the component.
@@ -218,7 +218,7 @@ With Strict Mode in React 18, React will simulate unmounting and remounting the
* React simulates unmounting the component.
* Layout effects are destroyed.
* Effects are destroyed.
-* React simulates mounting the component with the previous state.
+* React simulates mounting the Component with the previous state.
* Layout effects are created.
* Effects are created.
```
@@ -229,7 +229,7 @@ With Strict Mode in React 18, React will simulate unmounting and remounting the
#### useId {/*useid*/}
-`useId` is a new Hook for generating unique IDs on both the client and server, while avoiding hydration mismatches. It is primarily useful for component libraries integrating with accessibility APIs that require unique IDs. This solves an issue that already exists in React 17 and below, but it's even more important in React 18 because of how the new streaming server renderer delivers HTML out-of-order. [See docs here](/reference/react/useId).
+`useId` is a new Hook for generating unique IDs on both the client and server, while avoiding hydration mismatches. It is primarily useful for Component libraries integrating with accessibility APIs that require unique IDs. This solves an issue that already exists in React 17 and below, but it's even more important in React 18 because of how the new streaming server renderer delivers HTML out-of-order. [See docs here](/reference/react/useId).
> Note
>
@@ -277,10 +277,10 @@ See [How to Upgrade to React 18](/blog/2022/03/08/react-18-upgrade-guide) for st
* Assume Symbols are always available. ([#23348](https://github.com/facebook/react/pull/23348) by [@sebmarkbage](https://github.com/sebmarkbage))
* Remove `object-assign` polyfill. ([#23351](https://github.com/facebook/react/pull/23351) by [@sebmarkbage](https://github.com/sebmarkbage))
* Remove unsupported `unstable_changedBits` API. ([#20953](https://github.com/facebook/react/pull/20953) by [@acdlite](https://github.com/acdlite))
-* Allow components to render undefined. ([#21869](https://github.com/facebook/react/pull/21869) by [@rickhanlonii](https://github.com/rickhanlonii))
+* Allow Components to render undefined. ([#21869](https://github.com/facebook/react/pull/21869) by [@rickhanlonii](https://github.com/rickhanlonii))
* Flush `useEffect` resulting from discrete events like clicks synchronously. ([#21150](https://github.com/facebook/react/pull/21150) by [@acdlite](https://github.com/acdlite))
* Suspense `fallback={undefined}` now behaves the same as `null` and isn't ignored. ([#21854](https://github.com/facebook/react/pull/21854) by [@rickhanlonii](https://github.com/rickhanlonii))
-* Consider all `lazy()` resolving to the same component equivalent. ([#20357](https://github.com/facebook/react/pull/20357) by [@sebmarkbage](https://github.com/sebmarkbage))
+* Consider all `lazy()` resolving to the same Component equivalent. ([#20357](https://github.com/facebook/react/pull/20357) by [@sebmarkbage](https://github.com/sebmarkbage))
* Don't patch console during first render. ([#22308](https://github.com/facebook/react/pull/22308) by [@lunaruan](https://github.com/lunaruan))
* Improve memory usage. ([#21039](https://github.com/facebook/react/pull/21039) by [@bgirard](https://github.com/bgirard))
* Improve messages if string coercion throws (Temporal.*, Symbol, etc.) ([#22064](https://github.com/facebook/react/pull/22064) by [@justingrant](https://github.com/justingrant))
diff --git a/src/content/blog/2022/06/15/react-labs-what-we-have-been-working-on-june-2022.md b/src/content/blog/2022/06/15/react-labs-what-we-have-been-working-on-june-2022.md
index 5e8456ea3c5..be6d89e5729 100644
--- a/src/content/blog/2022/06/15/react-labs-what-we-have-been-working-on-june-2022.md
+++ b/src/content/blog/2022/06/15/react-labs-what-we-have-been-working-on-june-2022.md
@@ -49,7 +49,7 @@ We’re also working on a playground for exploring many aspects of the compiler.
Today, if you want to hide and show a component, you have two options. One is to add or remove it from the tree completely. The problem with this approach is that the state of your UI is lost each time you unmount, including state stored in the DOM, like scroll position.
-The other option is to keep the component mounted and toggle the appearance visually using CSS. This preserves the state of your UI, but it comes at a performance cost, because React must keep rendering the hidden component and all of its children whenever it receives new updates.
+The other option is to keep the Component mounted and toggle the appearance visually using CSS. This preserves the state of your UI, but it comes at a performance cost, because React must keep rendering the hidden Component and all of its children whenever it receives new updates.
Offscreen introduces a third option: hide the UI visually, but deprioritize its content. The idea is similar in spirit to the `content-visibility` CSS property: when content is hidden, it doesn't need to stay in sync with the rest of the UI. React can defer the rendering work until the rest of the app is idle, or until the content becomes visible again.
@@ -62,9 +62,9 @@ Offscreen is a low level capability that unlocks high level features. Similar to
## Transition Tracing {/*transition-tracing*/}
-Currently, React has two profiling tools. The [original Profiler](https://legacy.reactjs.org/blog/2018/09/10/introducing-the-react-profiler.html) shows an overview of all the commits in a profiling session. For each commit, it also shows all components that rendered and the amount of time it took for them to render. We also have a beta version of a [Timeline Profiler](https://github.com/reactwg/react-18/discussions/76) introduced in React 18 that shows when components schedule updates and when React works on these updates. Both of these profilers help developers identify performance problems in their code.
+Currently, React has two profiling tools. The [original Profiler](https://legacy.reactjs.org/blog/2018/09/10/introducing-the-react-profiler.html) shows an overview of all the commits in a profiling session. For each commit, it also shows all Components that rendered and the amount of time it took for them to render. We also have a beta version of a [Timeline Profiler](https://github.com/reactwg/react-18/discussions/76) introduced in React 18 that shows when Components schedule updates and when React works on these updates. Both of these profilers help developers identify performance problems in their code.
-We’ve realized that developers don’t find knowing about individual slow commits or components out of context that useful. It’s more useful to know about what actually causes the slow commits. And that developers want to be able to track specific interactions (eg a button click, an initial load, or a page navigation) to watch for performance regressions and to understand why an interaction was slow and how to fix it.
+We’ve realized that developers don’t find knowing about individual slow commits or Components out of context that useful. It’s more useful to know about what actually causes the slow commits. And that developers want to be able to track specific interactions (eg a button click, an initial load, or a page navigation) to watch for performance regressions and to understand why an interaction was slow and how to fix it.
We previously tried to solve this issue by creating an [Interaction Tracing API](https://gist.github.com/bvaughn/8de925562903afd2e7a12554adcdda16), but it had some fundamental design flaws that reduced the accuracy of tracking why an interaction was slow and sometimes resulted in interactions never ending. We ended up [removing this API](https://github.com/facebook/react/pull/20037) because of these issues.
diff --git a/src/content/blog/2023/03/16/introducing-react-dev.md b/src/content/blog/2023/03/16/introducing-react-dev.md
index 4ce209d7195..38099448d99 100644
--- a/src/content/blog/2023/03/16/introducing-react-dev.md
+++ b/src/content/blog/2023/03/16/introducing-react-dev.md
@@ -16,7 +16,7 @@ Today we are thrilled to launch [react.dev](https://react.dev), the new home for
## tl;dr {/*tldr*/}
-* The new React site ([react.dev](https://react.dev)) teaches modern React with function components and Hooks.
+* The new React site ([react.dev](https://react.dev)) teaches modern React with function Components and Hooks.
* We've included diagrams, illustrations, challenges, and over 600 new interactive examples.
* The previous React documentation site has now moved to [legacy.reactjs.org](https://legacy.reactjs.org).
@@ -34,7 +34,7 @@ If you haven't seen the new homepage yet, check it out!
## Going all-in on modern React with Hooks {/*going-all-in-on-modern-react-with-hooks*/}
-When we released React Hooks in 2018, the Hooks docs assumed the reader is familiar with class components. This helped the community adopt Hooks very swiftly, but after a while the old docs failed to serve the new readers. New readers had to learn React twice: once with class components and then once again with Hooks.
+When we released React Hooks in 2018, the Hooks docs assumed the reader is familiar with class components. This helped the community adopt Hooks very swiftly, but after a while the old docs failed to serve the new readers. New readers had to learn React twice: once with class Components and then once again with Hooks.
**The new docs teach React with Hooks from the beginning.** The docs are divided in two main sections:
@@ -45,7 +45,7 @@ Let's have a closer look at what you can find in each section.
-There are still a few rare class component use cases that do not yet have a Hook-based equivalent. Class components remain supported, and are documented in the [Legacy API](/reference/react/legacy) section of the new site.
+There are still a few rare class Component use cases that do not yet have a Hook-based equivalent. Class Components remain supported, and are documented in the [Legacy API](/reference/react/legacy) section of the new site.
@@ -222,7 +222,7 @@ body {
-We'd also like to highlight [Thinking in React](/learn/thinking-in-react)—that's the tutorial that made React "click" for many of us. **We've updated both of these classic tutorials to use function components and Hooks,** so they're as good as new.
+We'd also like to highlight [Thinking in React](/learn/thinking-in-react)—that's the tutorial that made React "click" for many of us. **We've updated both of these classic tutorials to use function Components and Hooks,** so they're as good as new.
@@ -440,7 +440,7 @@ Notice the "Show solution" button in the left bottom corner. It's handy if you w
When we couldn't figure out how to explain something with code and words alone, we've added diagrams that help provide some intuition. For example, here is one of the diagrams from [Preserving and Resetting State](/learn/preserving-and-resetting-state):
-
+
When `section` changes to `div`, the `section` is deleted and the new `div` is added
@@ -457,8 +457,8 @@ We've confirmed with the browser vendors that this depiction is 100% scientifica
In the [API Reference](/reference/react), every React API now has a dedicated page. This includes all kinds of APIs:
- Built-in Hooks like [`useState`](/reference/react/useState).
-- Built-in components like [``](/reference/react/Suspense).
-- Built-in browser components like [``](/reference/react-dom/components/input).
+- Built-in Components like [``](/reference/react/Suspense).
+- Built-in browser Components like [``](/reference/react-dom/components/input).
- Framework-oriented APIs like [`renderToPipeableStream`](/reference/react-dom/server/renderToReadableStream).
- Other React APIs like [`memo`](/reference/react/memo).
diff --git a/src/content/blog/2023/03/22/react-labs-what-we-have-been-working-on-march-2023.md b/src/content/blog/2023/03/22/react-labs-what-we-have-been-working-on-march-2023.md
index 1f6b911e1ed..2d8ad24b264 100644
--- a/src/content/blog/2023/03/22/react-labs-what-we-have-been-working-on-march-2023.md
+++ b/src/content/blog/2023/03/22/react-labs-what-we-have-been-working-on-march-2023.md
@@ -24,17 +24,17 @@ RSC combines the simple "request/response" mental model of server-centric Multi-
Since our last update, we have merged the [React Server Components RFC](https://github.com/reactjs/rfcs/blob/main/text/0188-server-components.md) to ratify the proposal. We resolved outstanding issues with the [React Server Module Conventions](https://github.com/reactjs/rfcs/blob/main/text/0227-server-module-conventions.md) proposal, and reached consensus with our partners to go with the `"use client"` convention. These documents also act as specification for what an RSC-compatible implementation should support.
-The biggest change is that we introduced [`async` / `await`](https://github.com/reactjs/rfcs/pull/229) as the primary way to do data fetching from Server Components. We also plan to support data loading from the client by introducing a new Hook called `use` that unwraps Promises. Although we can't support `async / await` in arbitrary components in client-only apps, we plan to add support for it when you structure your client-only app similar to how RSC apps are structured.
+The biggest change is that we introduced [`async` / `await`](https://github.com/reactjs/rfcs/pull/229) as the primary way to do data fetching from Server Components. We also plan to support data loading from the client by introducing a new Hook called `use` that unwraps Promises. Although we can't support `async / await` in arbitrary Components in client-only apps, we plan to add support for it when you structure your client-only app similar to how RSC apps are structured.
Now that we have data fetching pretty well sorted, we're exploring the other direction: sending data from the client to the server, so that you can execute database mutations and implement forms. We're doing this by letting you pass Server Action functions across the server/client boundary, which the client can then call, providing seamless RPC. Server Actions also give you progressively enhanced forms before JavaScript loads.
-React Server Components has shipped in [Next.js App Router](/learn/start-a-new-react-project#nextjs-app-router). This showcases a deep integration of a router that really buys into RSC as a primitive, but it's not the only way to build a RSC-compatible router and framework. There's a clear separation for features provided by the RSC spec and implementation. React Server Components is meant as a spec for components that work across compatible React frameworks.
+React Server Components has shipped in [Next.js App Router](/learn/start-a-new-react-project#nextjs-app-router). This showcases a deep integration of a router that really buys into RSC as a primitive, but it's not the only way to build a RSC-compatible router and framework. There's a clear separation for features provided by the RSC spec and implementation. React Server Components is meant as a spec for Components that work across compatible React frameworks.
We generally recommend using an existing framework, but if you need to build your own custom framework, it is possible. Building your own RSC-compatible framework is not as easy as we'd like it to be, mainly due to the deep bundler integration needed. The current generation of bundlers are great for use on the client, but they weren't designed with first-class support for splitting a single module graph between the server and the client. This is why we're now partnering directly with bundler developers to get the primitives for RSC built-in.
## Asset Loading {/*asset-loading*/}
-[Suspense](/reference/react/Suspense) lets you specify what to display on the screen while the data or code for your components is still being loaded. This lets your users progressively see more content while the page is loading as well as during the router navigations that load more data and code. However, from the user's perspective, data loading and rendering do not tell the whole story when considering whether new content is ready. By default, browsers load stylesheets, fonts, and images independently, which can lead to UI jumps and consecutive layout shifts.
+[Suspense](/reference/react/Suspense) lets you specify what to display on the screen while the data or code for your Components is still being loaded. This lets your users progressively see more content while the page is loading as well as during the router navigations that load more data and code. However, from the user's perspective, data loading and rendering do not tell the whole story when considering whether new content is ready. By default, browsers load stylesheets, fonts, and images independently, which can lead to UI jumps and consecutive layout shifts.
We're working to fully integrate Suspense with the loading lifecycle of stylesheets, fonts, and images, so that React takes them into account to determine whether the content is ready to be displayed. Without any change to the way you author your React components, updates will behave in a more coherent and pleasing manner. As an optimization, we will also provide a manual way to preload assets like fonts directly from components.
@@ -42,23 +42,23 @@ We are currently implementing these features and will have more to share soon.
## Document Metadata {/*document-metadata*/}
-Different pages and screens in your app may have different metadata like the `` tag, description, and other `` tags specific to this screen. From the maintenance perspective, it's more scalable to keep this information close to the React component for that page or screen. However, the HTML tags for this metadata need to be in the document `` which is typically rendered in a component at the very root of your app.
+Different pages and screens in your app may have different metadata like the `` tag, description, and other `` tags specific to this screen. From the maintenance perspective, it's more scalable to keep this information close to the React Component for that page or screen. However, the HTML tags for this metadata need to be in the document `` which is typically rendered in a Component at the very root of your app.
Today, people solve this problem with one of the two techniques.
-One technique is to render a special third-party component that moves ``, ``, and other tags inside it into the document ``. This works for major browsers but there are many clients which do not run client-side JavaScript, such as Open Graph parsers, and so this technique is not universally suitable.
+One technique is to render a special third-party Component that moves ``, ``, and other tags inside it into the document ``. This works for major browsers but there are many clients which do not run client-side JavaScript, such as Open Graph parsers, and so this technique is not universally suitable.
Another technique is to server-render the page in two parts. First, the main content is rendered and all such tags are collected. Then, the `` is rendered with these tags. Finally, the `` and the main content are sent to the browser. This approach works, but it prevents you from taking advantage of the [React 18's Streaming Server Renderer](/reference/react-dom/server/renderToReadableStream) because you'd have to wait for all content to render before sending the ``.
-This is why we're adding built-in support for rendering ``, ``, and metadata `` tags anywhere in your component tree out of the box. It would work the same way in all environments, including fully client-side code, SSR, and in the future, RSC. We will share more details about this soon.
+This is why we're adding built-in support for rendering ``, ``, and metadata `` tags anywhere in your Component tree out of the box. It would work the same way in all environments, including fully client-side code, SSR, and in the future, RSC. We will share more details about this soon.
## React Optimizing Compiler {/*react-optimizing-compiler*/}
Since our previous update we've been actively iterating on the design of [React Forget](/blog/2022/06/15/react-labs-what-we-have-been-working-on-june-2022#react-compiler), an optimizing compiler for React. We've previously talked about it as an "auto-memoizing compiler", and that is true in some sense. But building the compiler has helped us understand React's programming model even more deeply. A better way to understand React Forget is as an automatic *reactivity* compiler.
-The core idea of React is that developers define their UI as a function of the current state. You work with plain JavaScript values — numbers, strings, arrays, objects — and use standard JavaScript idioms — if/else, for, etc — to describe your component logic. The mental model is that React will re-render whenever the application state changes. We believe this simple mental model and keeping close to JavaScript semantics is an important principle in React's programming model.
+The core idea of React is that developers define their UI as a function of the current state. You work with plain JavaScript values — numbers, strings, arrays, objects — and use standard JavaScript idioms — if/else, for, etc — to describe your Component logic. The mental model is that React will re-render whenever the application state changes. We believe this simple mental model and keeping close to JavaScript semantics is an important principle in React's programming model.
-The catch is that React can sometimes be *too* reactive: it can re-render too much. For example, in JavaScript we don't have cheap ways to compare if two objects or arrays are equivalent (having the same keys and values), so creating a new object or array on each render may cause React to do more work than it strictly needs to. This means developers have to explicitly memoize components so as to not over-react to changes.
+The catch is that React can sometimes be *too* reactive: it can re-render too much. For example, in JavaScript we don't have cheap ways to compare if two objects or arrays are equivalent (having the same keys and values), so creating a new object or array on each render may cause React to do more work than it strictly needs to. This means developers have to explicitly memoize Components so as to not over-react to changes.
Our goal with React Forget is to ensure that React apps have just the right amount of reactivity by default: that apps re-render only when state values *meaningfully* change. From an implementation perspective this means automatically memoizing, but we believe that the reactivity framing is a better way to understand React and Forget. One way to think about this is that React currently re-renders when object identity changes. With Forget, React re-renders when the semantic value changes — but without incurring the runtime cost of deep comparisons.
@@ -70,20 +70,20 @@ The core of the compiler is almost completely decoupled from Babel, and the core
As we refactored the compiler over the last few months, we wanted to focus on refining the core compilation model to ensure we could handle complexities such as conditionals, loops, reassignment, and mutation. However, JavaScript has a lot of ways to express each of those features: if/else, ternaries, for, for-in, for-of, etc. Trying to support the full language up-front would have delayed the point where we could validate the core model. Instead, we started with a small but representative subset of the language: let/const, if/else, for loops, objects, arrays, primitives, function calls, and a few other features. As we gained confidence in the core model and refined our internal abstractions, we expanded the supported language subset. We're also explicit about syntax we don't yet support, logging diagnostics and skipping compilation for unsupported input. We have utilities to try the compiler on Meta's codebases and see what unsupported features are most common so we can prioritize those next. We'll continue incrementally expanding towards supporting the whole language.
-Making plain JavaScript in React components reactive requires a compiler with a deep understanding of semantics so that it can understand exactly what the code is doing. By taking this approach, we're creating a system for reactivity within JavaScript that lets you write product code of any complexity with the full expressivity of the language, instead of being limited to a domain specific language.
+Making plain JavaScript in React Components reactive requires a compiler with a deep understanding of semantics so that it can understand exactly what the code is doing. By taking this approach, we're creating a system for reactivity within JavaScript that lets you write product code of any complexity with the full expressivity of the language, instead of being limited to a domain specific language.
## Offscreen Rendering {/*offscreen-rendering*/}
Offscreen rendering is an upcoming capability in React for rendering screens in the background without additional performance overhead. You can think of it as a version of the [`content-visibility` CSS property](https://developer.mozilla.org/en-US/docs/Web/CSS/content-visibility) that works not only for DOM elements but React components, too. During our research, we've discovered a variety of use cases:
- A router can prerender screens in the background so that when a user navigates to them, they're instantly available.
-- A tab switching component can preserve the state of hidden tabs, so the user can switch between them without losing their progress.
-- A virtualized list component can prerender additional rows above and below the visible window.
+- A tab switching Component can preserve the state of hidden tabs, so the user can switch between them without losing their progress.
+- A virtualized list Component can prerender additional rows above and below the visible window.
- When opening a modal or popup, the rest of the app can be put into "background" mode so that events and updates are disabled for everything except the modal.
Most React developers will not interact with React's offscreen APIs directly. Instead, offscreen rendering will be integrated into things like routers and UI libraries, and then developers who use those libraries will automatically benefit without additional work.
-The idea is that you should be able to render any React tree offscreen without changing the way you write your components. When a component is rendered offscreen, it does not actually *mount* until the component becomes visible — its effects are not fired. For example, if a component uses `useEffect` to log analytics when it appears for the first time, prerendering won't mess up the accuracy of those analytics. Similarly, when a component goes offscreen, its effects are unmounted, too. A key feature of offscreen rendering is that you can toggle the visibility of a component without losing its state.
+The idea is that you should be able to render any React tree offscreen without changing the way you write your components. When a Component is rendered offscreen, it does not actually *mount* until the Component becomes visible — its effects are not fired. For example, if a Component uses `useEffect` to log analytics when it appears for the first time, prerendering won't mess up the accuracy of those analytics. Similarly, when a Component goes offscreen, its effects are unmounted, too. A key feature of offscreen rendering is that you can toggle the visibility of a Component without losing its state.
Since our last update, we've tested an experimental version of prerendering internally at Meta in our React Native apps on Android and iOS, with positive performance results. We've also improved how offscreen rendering works with Suspense — suspending inside an offscreen tree will not trigger Suspense fallbacks. Our remaining work involves finalizing the primitives that are exposed to library developers. We expect to publish an RFC later this year, alongside an experimental API for testing and feedback.
diff --git a/src/content/blog/2024/02/15/react-labs-what-we-have-been-working-on-february-2024.md b/src/content/blog/2024/02/15/react-labs-what-we-have-been-working-on-february-2024.md
index 03fc85c37fd..183b6ff1159 100644
--- a/src/content/blog/2024/02/15/react-labs-what-we-have-been-working-on-february-2024.md
+++ b/src/content/blog/2024/02/15/react-labs-what-we-have-been-working-on-february-2024.md
@@ -30,7 +30,7 @@ As discussed in our [previous post](/blog/2023/03/22/react-labs-what-we-have-bee
Manual memoization is a reasonable compromise, but we weren’t satisfied. Our vision is for React to *automatically* re-render just the right parts of the UI when state changes, *without compromising on React’s core mental model*. We believe that React’s approach — UI as a simple function of state, with standard JavaScript values and idioms — is a key part of why React has been approachable for so many developers. That’s why we’ve invested in building an optimizing compiler for React.
-JavaScript is a notoriously challenging language to optimize, thanks to its loose rules and dynamic nature. React Compiler is able to compile code safely by modeling both the rules of JavaScript *and* the “rules of React”. For example, React components must be idempotent — returning the same value given the same inputs — and can’t mutate props or state values. These rules limit what developers can do and help to carve out a safe space for the compiler to optimize.
+JavaScript is a notoriously challenging language to optimize, thanks to its loose rules and dynamic nature. React Compiler is able to compile code safely by modeling both the rules of JavaScript *and* the “rules of React”. For example, React Components must be idempotent — returning the same value given the same inputs — and can’t mutate props or state values. These rules limit what developers can do and help to carve out a safe space for the compiler to optimize.
Of course, we understand that developers sometimes bend the rules a bit, and our goal is to make React Compiler work out of the box on as much code as possible. The compiler attempts to detect when code doesn’t strictly follow React’s rules and will either compile the code where safe or skip compilation if it isn’t safe. We’re testing against Meta’s large and varied codebase in order to help validate this approach.
@@ -58,7 +58,7 @@ By default, Actions are submitted within a [transition](/reference/react/useTran
Alongside Actions, we're introducing a feature named [`useOptimistic`](/reference/react/useOptimistic) for managing optimistic state updates. With this hook, you can apply temporary updates that are automatically reverted once the final state commits. For Actions, this allows you to optimistically set the final state of the data on the client, assuming the submission is successful, and revert to the value for data received from the server. It works using regular `async`/`await`, so it works the same whether you're using `fetch` on the client, or a Server Action from the server.
-Library authors can implement custom `action={fn}` props in their own components with `useTransition`. Our intent is for libraries to adopt the Actions pattern when designing their component APIs, to provide a consistent experience for React developers. For example, if your library provides a `` component, consider also exposing a `` API, too.
+Library authors can implement custom `action={fn}` props in their own Components with `useTransition`. Our intent is for libraries to adopt the Actions pattern when designing their Component APIs, to provide a consistent experience for React developers. For example, if your library provides a `` component, consider also exposing a `` API, too.
While we initially focused on Server Actions for client-server data transfer, our philosophy for React is to provide the same programming model across all platforms and environments. When possible, if we introduce a feature on the client, we aim to make it also work on the server, and vice versa. This philosophy allows us to create a single set of APIs that work no matter where your app runs, making it easier to upgrade to different environments later.
@@ -72,9 +72,9 @@ Canaries are a change to the way we develop React. Previously, features would be
React Server Components, Asset Loading, Document Metadata, and Actions have all landed in the React Canary, and we've added docs for these features on react.dev:
-- **Directives**: [`"use client"`](/reference/react/use-client) and [`"use server"`](/reference/react/use-server) are bundler features designed for full-stack React frameworks. They mark the "split points" between the two environments: `"use client"` instructs the bundler to generate a `
@@ -68,7 +68,7 @@ Props that are **not recommended** for use with React:
#### Special rendering behavior {/*special-rendering-behavior*/}
-React can move `
```
@@ -141,7 +141,7 @@ This will attach event listeners to the server-generated HTML and make it intera
The final asset URLs (like JavaScript and CSS files) are often hashed after the build. For example, instead of `styles.css` you might end up with `styles.123456.css`. Hashing static asset filenames guarantees that every distinct build of the same asset will have a different filename. This is useful because it lets you safely enable long-term caching for static assets: a file with a certain name would never change content.
-However, if you don't know the asset URLs until after the build, there's no way for you to put them in the source code. For example, hardcoding `"/styles.css"` into JSX like earlier wouldn't work. To keep them out of your source code, your root component can read the real filenames from a map passed as a prop:
+However, if you don't know the asset URLs until after the build, there's no way for you to put them in the source code. For example, hardcoding `"/styles.css"` into JSX like earlier wouldn't work. To keep them out of your source code, your root Component can read the real filenames from a map passed as a prop:
```js {1,6}
export default function App({ assetMap }) {
@@ -287,12 +287,12 @@ Streaming does not need to wait for React itself to load in the browser, or for
**Only Suspense-enabled data sources will activate the Suspense component.** They include:
- Data fetching with Suspense-enabled frameworks like [Relay](https://relay.dev/docs/guided-tour/rendering/loading-states/) and [Next.js](https://nextjs.org/docs/getting-started/react-essentials)
-- Lazy-loading component code with [`lazy`](/reference/react/lazy)
+- Lazy-loading Component code with [`lazy`](/reference/react/lazy)
- Reading the value of a Promise with [`use`](/reference/react/use)
Suspense **does not** detect when data is fetched inside an Effect or event handler.
-The exact way you would load data in the `Posts` component above depends on your framework. If you use a Suspense-enabled framework, you'll find the details in its data fetching documentation.
+The exact way you would load data in the `Posts` Component above depends on your framework. If you use a Suspense-enabled framework, you'll find the details in its data fetching documentation.
Suspense-enabled data fetching without the use of an opinionated framework is not yet supported. The requirements for implementing a Suspense-enabled data source are unstable and undocumented. An official API for integrating data sources with Suspense will be released in a future version of React.
@@ -346,7 +346,7 @@ const { pipe } = renderToPipeableStream(, {
});
```
-By the time `onShellReady` fires, components in nested `` boundaries might still be loading data.
+By the time `onShellReady` fires, Components in nested `` boundaries might still be loading data.
---
@@ -416,7 +416,7 @@ If there is an error while generating the shell, both `onError` and `onShellErro
### Recovering from errors outside the shell {/*recovering-from-errors-outside-the-shell*/}
-In this example, the `` component is wrapped in `` so it is *not* a part of the shell:
+In this example, the `` Component is wrapped in `` so it is *not* a part of the shell:
```js {6}
function ProfilePage() {
@@ -431,7 +431,7 @@ function ProfilePage() {
}
```
-If an error happens in the `Posts` component or somewhere inside it, React will [try to recover from it:](/reference/react/Suspense#providing-a-fallback-for-server-errors-and-client-only-content)
+If an error happens in the `Posts` Component or somewhere inside it, React will [try to recover from it:](/reference/react/Suspense#providing-a-fallback-for-server-errors-and-client-only-content)
1. It will emit the loading fallback for the closest `` boundary (`PostsGlimmer`) into the HTML.
2. It will "give up" on trying to render the `Posts` content on the server anymore.
@@ -469,7 +469,7 @@ const { pipe } = renderToPipeableStream(, {
});
```
-If a component *outside* the shell (i.e. inside a `` boundary) throws an error, React will not stop rendering. This means that the `onError` callback will fire, but you will still get `onShellReady` instead of `onShellError`. This is because React will try to recover from that error on the client, [as described above.](#recovering-from-errors-outside-the-shell)
+If a Component *outside* the shell (i.e. inside a `` boundary) throws an error, React will not stop rendering. This means that the `onError` callback will fire, but you will still get `onShellReady` instead of `onShellError`. This is because React will try to recover from that error on the client, [as described above.](#recovering-from-errors-outside-the-shell)
However, if you'd like, you can use the fact that something has errored to set the status code:
diff --git a/src/content/reference/react-dom/server/renderToReadableStream.md b/src/content/reference/react-dom/server/renderToReadableStream.md
index f407f2245f4..a5927b9d118 100644
--- a/src/content/reference/react-dom/server/renderToReadableStream.md
+++ b/src/content/reference/react-dom/server/renderToReadableStream.md
@@ -47,7 +47,7 @@ On the client, call [`hydrateRoot`](/reference/react-dom/client/hydrateRoot) to
#### Parameters {/*parameters*/}
-* `reactNode`: A React node you want to render to HTML. For example, a JSX element like ``. It is expected to represent the entire document, so the `App` component should render the `` tag.
+* `reactNode`: A React node you want to render to HTML. For example, a JSX element like ``. It is expected to represent the entire document, so the `App` Component should render the `` tag.
* **optional** `options`: An object with streaming options.
* **optional** `bootstrapScriptContent`: If specified, this string will be placed in an inline `
```
@@ -142,7 +142,7 @@ This will attach event listeners to the server-generated HTML and make it intera
The final asset URLs (like JavaScript and CSS files) are often hashed after the build. For example, instead of `styles.css` you might end up with `styles.123456.css`. Hashing static asset filenames guarantees that every distinct build of the same asset will have a different filename. This is useful because it lets you safely enable long-term caching for static assets: a file with a certain name would never change content.
-However, if you don't know the asset URLs until after the build, there's no way for you to put them in the source code. For example, hardcoding `"/styles.css"` into JSX like earlier wouldn't work. To keep them out of your source code, your root component can read the real filenames from a map passed as a prop:
+However, if you don't know the asset URLs until after the build, there's no way for you to put them in the source code. For example, hardcoding `"/styles.css"` into JSX like earlier wouldn't work. To keep them out of your source code, your root Component can read the real filenames from a map passed as a prop:
```js {1,6}
export default function App({ assetMap }) {
@@ -286,12 +286,12 @@ Streaming does not need to wait for React itself to load in the browser, or for
**Only Suspense-enabled data sources will activate the Suspense component.** They include:
- Data fetching with Suspense-enabled frameworks like [Relay](https://relay.dev/docs/guided-tour/rendering/loading-states/) and [Next.js](https://nextjs.org/docs/getting-started/react-essentials)
-- Lazy-loading component code with [`lazy`](/reference/react/lazy)
+- Lazy-loading Component code with [`lazy`](/reference/react/lazy)
- Reading the value of a Promise with [`use`](/reference/react/use)
Suspense **does not** detect when data is fetched inside an Effect or event handler.
-The exact way you would load data in the `Posts` component above depends on your framework. If you use a Suspense-enabled framework, you'll find the details in its data fetching documentation.
+The exact way you would load data in the `Posts` Component above depends on your framework. If you use a Suspense-enabled framework, you'll find the details in its data fetching documentation.
Suspense-enabled data fetching without the use of an opinionated framework is not yet supported. The requirements for implementing a Suspense-enabled data source are unstable and undocumented. An official API for integrating data sources with Suspense will be released in a future version of React.
@@ -346,7 +346,7 @@ async function handler(request) {
}
```
-By the time the `stream` is returned, components in nested `` boundaries might still be loading data.
+By the time the `stream` is returned, Components in nested `` boundaries might still be loading data.
---
@@ -420,7 +420,7 @@ If there is an error while generating the shell, both `onError` and your `catch`
### Recovering from errors outside the shell {/*recovering-from-errors-outside-the-shell*/}
-In this example, the `` component is wrapped in `` so it is *not* a part of the shell:
+In this example, the `` Component is wrapped in `` so it is *not* a part of the shell:
```js {6}
function ProfilePage() {
@@ -435,7 +435,7 @@ function ProfilePage() {
}
```
-If an error happens in the `Posts` component or somewhere inside it, React will [try to recover from it:](/reference/react/Suspense#providing-a-fallback-for-server-errors-and-client-only-content)
+If an error happens in the `Posts` Component or somewhere inside it, React will [try to recover from it:](/reference/react/Suspense#providing-a-fallback-for-server-errors-and-client-only-content)
1. It will emit the loading fallback for the closest `` boundary (`PostsGlimmer`) into the HTML.
2. It will "give up" on trying to render the `Posts` content on the server anymore.
@@ -476,7 +476,7 @@ async function handler(request) {
}
```
-If a component *outside* the shell (i.e. inside a `` boundary) throws an error, React will not stop rendering. This means that the `onError` callback will fire, but your code will continue running without getting into the `catch` block. This is because React will try to recover from that error on the client, [as described above.](#recovering-from-errors-outside-the-shell)
+If a Component *outside* the shell (i.e. inside a `` boundary) throws an error, React will not stop rendering. This means that the `onError` callback will fire, but your code will continue running without getting into the `catch` block. This is because React will try to recover from that error on the client, [as described above.](#recovering-from-errors-outside-the-shell)
However, if you'd like, you can use the fact that something has errored to set the status code:
diff --git a/src/content/reference/react-dom/server/renderToStaticMarkup.md b/src/content/reference/react-dom/server/renderToStaticMarkup.md
index 2b9178d550e..da0e0484c27 100644
--- a/src/content/reference/react-dom/server/renderToStaticMarkup.md
+++ b/src/content/reference/react-dom/server/renderToStaticMarkup.md
@@ -46,9 +46,9 @@ An HTML string.
* `renderToStaticMarkup` output cannot be hydrated.
-* `renderToStaticMarkup` has limited Suspense support. If a component suspends, `renderToStaticMarkup` immediately sends its fallback as HTML.
+* `renderToStaticMarkup` has limited Suspense support. If a Component suspends, `renderToStaticMarkup` immediately sends its fallback as HTML.
-* `renderToStaticMarkup` works in the browser, but using it in the client code is not recommended. If you need to render a component to HTML in the browser, [get the HTML by rendering it into a DOM node.](/reference/react-dom/server/renderToString#removing-rendertostring-from-the-client-code)
+* `renderToStaticMarkup` works in the browser, but using it in the client code is not recommended. If you need to render a Component to HTML in the browser, [get the HTML by rendering it into a DOM node.](/reference/react-dom/server/renderToString#removing-rendertostring-from-the-client-code)
---
diff --git a/src/content/reference/react-dom/server/renderToString.md b/src/content/reference/react-dom/server/renderToString.md
index d9f1bdba426..7a4656b0956 100644
--- a/src/content/reference/react-dom/server/renderToString.md
+++ b/src/content/reference/react-dom/server/renderToString.md
@@ -51,7 +51,7 @@ An HTML string.
#### Caveats {/*caveats*/}
-* `renderToString` has limited Suspense support. If a component suspends, `renderToString` immediately sends its fallback as HTML.
+* `renderToString` has limited Suspense support. If a Component suspends, `renderToString` immediately sends its fallback as HTML.
* `renderToString` works in the browser, but using it in the client code is [not recommended.](#removing-rendertostring-from-the-client-code)
@@ -101,7 +101,7 @@ You can continue using `renderToString` if your server environment does not supp
### Removing `renderToString` from the client code {/*removing-rendertostring-from-the-client-code*/}
-Sometimes, `renderToString` is used on the client to convert some component to HTML.
+Sometimes, `renderToString` is used on the client to convert some Component to HTML.
```js {1-2}
// 🚩 Unnecessary: using renderToString on the client
@@ -111,7 +111,7 @@ const html = renderToString();
console.log(html); // For example, ""
```
-Importing `react-dom/server` **on the client** unnecessarily increases your bundle size and should be avoided. If you need to render some component to HTML in the browser, use [`createRoot`](/reference/react-dom/client/createRoot) and read HTML from the DOM:
+Importing `react-dom/server` **on the client** unnecessarily increases your bundle size and should be avoided. If you need to render some Component to HTML in the browser, use [`createRoot`](/reference/react-dom/client/createRoot) and read HTML from the DOM:
```js
import { createRoot } from 'react-dom/client';
@@ -131,11 +131,11 @@ The [`flushSync`](/reference/react-dom/flushSync) call is necessary so that the
## Troubleshooting {/*troubleshooting*/}
-### When a component suspends, the HTML always contains a fallback {/*when-a-component-suspends-the-html-always-contains-a-fallback*/}
+### When a Component suspends, the HTML always contains a fallback {/*when-a-component-suspends-the-html-always-contains-a-fallback*/}
`renderToString` does not fully support Suspense.
-If some component suspends (for example, because it's defined with [`lazy`](/reference/react/lazy) or fetches data), `renderToString` will not wait for its content to resolve. Instead, `renderToString` will find the closest [``](/reference/react/Suspense) boundary above it and render its `fallback` prop in the HTML. The content will not appear until the client code loads.
+If some Component suspends (for example, because it's defined with [`lazy`](/reference/react/lazy) or fetches data), `renderToString` will not wait for its content to resolve. Instead, `renderToString` will find the closest [``](/reference/react/Suspense) boundary above it and render its `fallback` prop in the HTML. The content will not appear until the client code loads.
To solve this, use one of the [recommended streaming solutions.](#migrating-from-rendertostring-to-a-streaming-method-on-the-server) They can stream content in chunks as it resolves on the server so that the user sees the page being progressively filled in before the client code loads.
diff --git a/src/content/reference/react-dom/unmountComponentAtNode.md b/src/content/reference/react-dom/unmountComponentAtNode.md
index 376a9bc2bfb..3cb76d07406 100644
--- a/src/content/reference/react-dom/unmountComponentAtNode.md
+++ b/src/content/reference/react-dom/unmountComponentAtNode.md
@@ -12,7 +12,7 @@ In React 18, `unmountComponentAtNode` was replaced by [`root.unmount()`](/refere
-`unmountComponentAtNode` removes a mounted React component from the DOM.
+`unmountComponentAtNode` removes a mounted React Component from the DOM.
```js
unmountComponentAtNode(domNode)
@@ -28,7 +28,7 @@ unmountComponentAtNode(domNode)
### `unmountComponentAtNode(domNode)` {/*unmountcomponentatnode*/}
-Call `unmountComponentAtNode` to remove a mounted React component from the DOM and clean up its event handlers and state.
+Call `unmountComponentAtNode` to remove a mounted React Component from the DOM and clean up its event handlers and state.
```js
import { unmountComponentAtNode } from 'react-dom';
@@ -43,11 +43,11 @@ unmountComponentAtNode(domNode);
#### Parameters {/*parameters*/}
-* `domNode`: A [DOM element.](https://developer.mozilla.org/en-US/docs/Web/API/Element) React will remove a mounted React component from this element.
+* `domNode`: A [DOM element.](https://developer.mozilla.org/en-US/docs/Web/API/Element) React will remove a mounted React Component from this element.
#### Returns {/*returns*/}
-`unmountComponentAtNode` returns `true` if a component was unmounted and `false` otherwise.
+`unmountComponentAtNode` returns `true` if a Component was unmounted and `false` otherwise.
---
diff --git a/src/content/reference/react/Children.md b/src/content/reference/react/Children.md
index 81a28c5b38d..798a41e914d 100644
--- a/src/content/reference/react/Children.md
+++ b/src/content/reference/react/Children.md
@@ -196,7 +196,7 @@ Returns a flat array of elements in `children`.
### Transforming children {/*transforming-children*/}
-To transform the children JSX that your component [receives as the `children` prop,](/learn/passing-props-to-a-component#passing-jsx-as-children) call `Children.map`:
+To transform the children JSX that your Component [receives as the `children` prop,](/learn/passing-props-to-a-component#passing-jsx-as-children) call `Children.map`:
```js {6,10}
import { Children } from 'react';
@@ -214,7 +214,7 @@ function RowList({ children }) {
}
```
-In the example above, the `RowList` wraps every child it receives into a `
` container. For example, let's say the parent component passes three `
` tags as the `children` prop to `RowList`:
+In the example above, the `RowList` wraps every child it receives into a `
` container. For example, let's say the parent Component passes three `
` tags as the `children` prop to `RowList`:
```js
@@ -305,7 +305,7 @@ Even when `children` is an array, `Children.map` has useful special behavior. Fo
-The `children` data structure **does not include rendered output** of the components you pass as JSX. In the example below, the `children` received by the `RowList` only contains two items rather than three:
+The `children` data structure **does not include rendered output** of the Components you pass as JSX. In the example below, the `children` received by the `RowList` only contains two items rather than three:
1. `
This is the first item.
`
2. ``
@@ -413,7 +413,7 @@ export default function SeparatorList({ children }) {
-As mentioned earlier, there is no way to get the rendered output of an inner component when manipulating `children`. This is why [it's usually better to use one of the alternative solutions.](#alternatives)
+As mentioned earlier, there is no way to get the rendered output of an inner Component when manipulating `children`. This is why [it's usually better to use one of the alternative solutions.](#alternatives)
@@ -484,7 +484,7 @@ export default function RowList({ children }) {
-As mentioned earlier, there is no way to get the rendered output of an inner component when manipulating `children`. This is why [it's usually better to use one of the alternative solutions.](#alternatives)
+As mentioned earlier, there is no way to get the rendered output of an inner Component when manipulating `children`. This is why [it's usually better to use one of the alternative solutions.](#alternatives)
@@ -524,7 +524,7 @@ export default function ReversedList({ children }) {
-As mentioned earlier, there is no way to get the rendered output of an inner component when manipulating `children`. This is why [it's usually better to use one of the alternative solutions.](#alternatives)
+As mentioned earlier, there is no way to get the rendered output of an inner Component when manipulating `children`. This is why [it's usually better to use one of the alternative solutions.](#alternatives)
@@ -544,9 +544,9 @@ Don't confuse it with [using the `children` prop](/learn/passing-props-to-a-comp
-### Exposing multiple components {/*exposing-multiple-components*/}
+### Exposing multiple Components {/*exposing-multiple-components*/}
-Manipulating children with the `Children` methods often leads to fragile code. When you pass children to a component in JSX, you don't usually expect the component to manipulate or transform the individual children.
+Manipulating children with the `Children` methods often leads to fragile code. When you pass children to a Component in JSX, you don't usually expect the Component to manipulate or transform the individual children.
When you can, try to avoid using the `Children` methods. For example, if you want every child of `RowList` to be wrapped in `
`, export a `Row` component, and manually wrap every row into it like this:
@@ -729,9 +729,9 @@ export function RowList({ rows }) {
-Since `rows` is a regular JavaScript array, the `RowList` component can use built-in array methods like [`map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) on it.
+Since `rows` is a regular JavaScript array, the `RowList` Component can use built-in array methods like [`map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) on it.
-This pattern is especially useful when you want to be able to pass more information as structured data together with children. In the below example, the `TabSwitcher` component receives an array of objects as the `tabs` prop:
+This pattern is especially useful when you want to be able to pass more information as structured data together with children. In the below example, the `TabSwitcher` Component receives an array of objects as the `tabs` prop:
@@ -795,7 +795,7 @@ Unlike passing the children as JSX, this approach lets you associate some extra
### Calling a render prop to customize rendering {/*calling-a-render-prop-to-customize-rendering*/}
-Instead of producing JSX for every single item, you can also pass a function that returns JSX, and call that function when necessary. In this example, the `App` component passes a `renderContent` function to the `TabSwitcher` component. The `TabSwitcher` component calls `renderContent` only for the selected tab:
+Instead of producing JSX for every single item, you can also pass a function that returns JSX, and call that function when necessary. In this example, the `App` Component passes a `renderContent` function to the `TabSwitcher` component. The `TabSwitcher` Component calls `renderContent` only for the selected tab:
@@ -846,7 +846,7 @@ export default function TabSwitcher({ tabIds, getHeader, renderContent }) {
A prop like `renderContent` is called a *render prop* because it is a prop that specifies how to render a piece of the user interface. However, there is nothing special about it: it is a regular prop which happens to be a function.
-Render props are functions, so you can pass information to them. For example, this `RowList` component passes the `id` and the `index` of each row to the `renderRow` render prop, which uses `index` to highlight even rows:
+Render props are functions, so you can pass information to them. For example, this `RowList` Component passes the `id` and the `index` of each row to the `renderRow` render prop, which uses `index` to highlight even rows:
@@ -927,7 +927,7 @@ export function Row({ children, isHighlighted }) {
-This is another example of how parent and child components can cooperate without manipulating the children.
+This is another example of how parent and child Components can cooperate without manipulating the children.
---
diff --git a/src/content/reference/react/Component.md b/src/content/reference/react/Component.md
index 46406ff5e5d..a07ffcd3297 100644
--- a/src/content/reference/react/Component.md
+++ b/src/content/reference/react/Component.md
@@ -4,13 +4,13 @@ title: Component
-We recommend defining components as functions instead of classes. [See how to migrate.](#alternatives)
+We recommend defining Components as functions instead of classes. [See how to migrate.](#alternatives)
-`Component` is the base class for the React components defined as [JavaScript classes.](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) Class components are still supported by React, but we don't recommend using them in new code.
+`Component` is the base class for the React Components defined as [JavaScript classes.](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) Class Components are still supported by React, but we don't recommend using them in new code.
```js
class Greeting extends Component {
@@ -30,7 +30,7 @@ class Greeting extends Component {
### `Component` {/*component*/}
-To define a React component as a class, extend the built-in `Component` class and define a [`render` method:](#render)
+To define a React Component as a class, extend the built-in `Component` class and define a [`render` method:](#render)
```js
import { Component } from 'react';
@@ -50,9 +50,9 @@ Only the `render` method is required, other methods are optional.
### `context` {/*context*/}
-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) (modern) or [`static contextTypes`](#static-contexttypes) (deprecated).
+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) (modern) or [`static contextTypes`](#static-contexttypes) (deprecated).
-A class component can only read one context at a time.
+A class Component can only read one context at a time.
```js {2,5}
class Button extends Component {
@@ -73,7 +73,7 @@ class Button extends Component {
-Reading `this.context` in class components is equivalent to [`useContext`](/reference/react/useContext) in function components.
+Reading `this.context` in class Components is equivalent to [`useContext`](/reference/react/useContext) in function components.
[See how to migrate.](#migrating-a-component-with-context-from-a-class-to-a-function)
@@ -83,7 +83,7 @@ Reading `this.context` in class components is equivalent to [`useContext`](/refe
### `props` {/*props*/}
-The props passed to a class component are available as `this.props`.
+The props passed to a class Component are available as `this.props`.
```js {3}
class Greeting extends Component {
@@ -97,7 +97,7 @@ class Greeting extends Component {
-Reading `this.props` in class components is equivalent to [declaring props](/learn/passing-props-to-a-component#step-2-read-props-inside-the-child-component) in function components.
+Reading `this.props` in class Components is equivalent to [declaring props](/learn/passing-props-to-a-component#step-2-read-props-inside-the-child-component) in function components.
[See how to migrate.](#migrating-a-simple-component-from-a-class-to-a-function)
@@ -119,7 +119,7 @@ Lets you access [legacy string refs](https://reactjs.org/docs/refs-and-the-dom.h
### `state` {/*state*/}
-The state of a class component is available as `this.state`. The `state` field must be an object. Do not mutate the state directly. If you wish to change the state, call `setState` with the new state.
+The state of a class Component is available as `this.state`. The `state` field must be an object. Do not mutate the state directly. If you wish to change the state, call `setState` with the new state.
```js {2-4,7-9,18}
class Counter extends Component {
@@ -148,7 +148,7 @@ class Counter extends Component {
-Defining `state` in class components is equivalent to calling [`useState`](/reference/react/useState) in function components.
+Defining `state` in class Components is equivalent to calling [`useState`](/reference/react/useState) in function components.
[See how to migrate.](#migrating-a-component-with-state-from-a-class-to-a-function)
@@ -158,7 +158,7 @@ Defining `state` in class components is equivalent to calling [`useState`](/refe
### `constructor(props)` {/*constructor*/}
-The [constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/constructor) runs before your class component *mounts* (gets added to the screen). Typically, a constructor is only used for two purposes in React. It lets you declare state and [bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_objects/Function/bind) your class methods to the class instance:
+The [constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/constructor) runs before your class Component *mounts* (gets added to the screen). Typically, a constructor is only used for two purposes in React. It lets you declare state and [bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_objects/Function/bind) your class methods to the class instance:
```js {2-6}
class Counter extends Component {
@@ -216,9 +216,9 @@ There is no exact equivalent for `constructor` in function components. To declar
### `componentDidCatch(error, info)` {/*componentdidcatch*/}
-If you define `componentDidCatch`, React will call it when some child component (including distant children) throws an error during rendering. This lets you log that error to an error reporting service in production.
+If you define `componentDidCatch`, React will call it when some child Component (including distant children) throws an error during rendering. This lets you log that error to an error reporting service in production.
-Typically, it is used together with [`static getDerivedStateFromError`](#static-getderivedstatefromerror) which lets you update state in response to an error and display an error message to the user. A component with these methods is called an *error boundary.*
+Typically, it is used together with [`static getDerivedStateFromError`](#static-getderivedstatefromerror) which lets you update state in response to an error and display an error message to the user. A Component with these methods is called an *error boundary.*
[See an example.](#catching-rendering-errors-with-an-error-boundary)
@@ -226,7 +226,7 @@ Typically, it is used together with [`static getDerivedStateFromError`](#static-
* `error`: The error that was thrown. In practice, it will usually be an instance of [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) but this is not guaranteed because JavaScript allows to [`throw`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/throw) any value, including strings or even `null`.
-* `info`: An object containing additional information about the error. Its `componentStack` field contains a stack trace with the component that threw, as well as the names and source locations of all its parent components. In production, the component names will be minified. If you set up production error reporting, you can decode the component stack using sourcemaps the same way as you would do for regular JavaScript error stacks.
+* `info`: An object containing additional information about the error. Its `componentStack` field contains a stack trace with the Component that threw, as well as the names and source locations of all its parent components. In production, the Component names will be minified. If you set up production error reporting, you can decode the Component stack using sourcemaps the same way as you would do for regular JavaScript error stacks.
#### Returns {/*componentdidcatch-returns*/}
@@ -240,7 +240,7 @@ Typically, it is used together with [`static getDerivedStateFromError`](#static-
-There is no direct equivalent for `componentDidCatch` in function components yet. If you'd like to avoid creating class components, write a single `ErrorBoundary` component like above and use it throughout your app. Alternatively, you can use the [`react-error-boundary`](https://github.com/bvaughn/react-error-boundary) package which does that for you.
+There is no direct equivalent for `componentDidCatch` in function Components yet. If you'd like to avoid creating class components, write a single `ErrorBoundary` Component like above and use it throughout your app. Alternatively, you can use the [`react-error-boundary`](https://github.com/bvaughn/react-error-boundary) package which does that for you.
@@ -248,7 +248,7 @@ There is no direct equivalent for `componentDidCatch` in function components yet
### `componentDidMount()` {/*componentdidmount*/}
-If you define the `componentDidMount` method, React will call it when your component is added *(mounted)* to the screen. This is a common place to start data fetching, set up subscriptions, or manipulate the DOM nodes.
+If you define the `componentDidMount` method, React will call it when your Component is added *(mounted)* to the screen. This is a common place to start data fetching, set up subscriptions, or manipulate the DOM nodes.
If you implement `componentDidMount`, you usually need to implement other lifecycle methods to avoid bugs. For example, if `componentDidMount` reads some state or props, you also have to implement [`componentDidUpdate`](#componentdidupdate) to handle their changes, and [`componentWillUnmount`](#componentwillunmount) to clean up whatever `componentDidMount` was doing.
@@ -298,7 +298,7 @@ class ChatRoom extends Component {
-For many use cases, defining `componentDidMount`, `componentDidUpdate`, and `componentWillUnmount` together in class components is equivalent to calling [`useEffect`](/reference/react/useEffect) in function components. In the rare cases where it's important for the code to run before browser paint, [`useLayoutEffect`](/reference/react/useLayoutEffect) is a closer match.
+For many use cases, defining `componentDidMount`, `componentDidUpdate`, and `componentWillUnmount` together in class Components is equivalent to calling [`useEffect`](/reference/react/useEffect) in function components. In the rare cases where it's important for the code to run before browser paint, [`useLayoutEffect`](/reference/react/useLayoutEffect) is a closer match.
[See how to migrate.](#migrating-a-component-with-lifecycle-methods-from-a-class-to-a-function)
@@ -308,7 +308,7 @@ For many use cases, defining `componentDidMount`, `componentDidUpdate`, and `com
### `componentDidUpdate(prevProps, prevState, snapshot?)` {/*componentdidupdate*/}
-If you define the `componentDidUpdate` method, React will call it immediately after your component has been re-rendered with updated props or state. This method is not called for the initial render.
+If you define the `componentDidUpdate` method, React will call it immediately after your Component has been re-rendered with updated props or state. This method is not called for the initial render.
You can use it to manipulate the DOM after an update. This is also a common place to do network requests as long as you compare the current props to previous props (e.g. a network request may not be necessary if the props have not changed). Typically, you'd use it together with [`componentDidMount`](#componentdidmount) and [`componentWillUnmount`:](#componentwillunmount)
@@ -365,7 +365,7 @@ class ChatRoom extends Component {
-For many use cases, defining `componentDidMount`, `componentDidUpdate`, and `componentWillUnmount` together in class components is equivalent to calling [`useEffect`](/reference/react/useEffect) in function components. In the rare cases where it's important for the code to run before browser paint, [`useLayoutEffect`](/reference/react/useLayoutEffect) is a closer match.
+For many use cases, defining `componentDidMount`, `componentDidUpdate`, and `componentWillUnmount` together in class Components is equivalent to calling [`useEffect`](/reference/react/useEffect) in function components. In the rare cases where it's important for the code to run before browser paint, [`useLayoutEffect`](/reference/react/useLayoutEffect) is a closer match.
[See how to migrate.](#migrating-a-component-with-lifecycle-methods-from-a-class-to-a-function)
@@ -410,7 +410,7 @@ Run the [`rename-unsafe-lifecycles` codemod](https://github.com/reactjs/react-co
### `componentWillUnmount()` {/*componentwillunmount*/}
-If you define the `componentWillUnmount` method, React will call it before your component is removed *(unmounted)* from the screen. This is a common place to cancel data fetching or remove subscriptions.
+If you define the `componentWillUnmount` method, React will call it before your Component is removed *(unmounted)* from the screen. This is a common place to cancel data fetching or remove subscriptions.
The logic inside `componentWillUnmount` should "mirror" the logic inside [`componentDidMount`.](#componentdidmount) For example, if `componentDidMount` sets up a subscription, `componentWillUnmount` should clean up that subscription. If the cleanup logic in your `componentWillUnmount` reads some props or state, you will usually also need to implement [`componentDidUpdate`](#componentdidupdate) to clean up resources (such as subscriptions) corresponding to the old props and state.
@@ -458,7 +458,7 @@ class ChatRoom extends Component {
-For many use cases, defining `componentDidMount`, `componentDidUpdate`, and `componentWillUnmount` together in class components is equivalent to calling [`useEffect`](/reference/react/useEffect) in function components. In the rare cases where it's important for the code to run before browser paint, [`useLayoutEffect`](/reference/react/useLayoutEffect) is a closer match.
+For many use cases, defining `componentDidMount`, `componentDidUpdate`, and `componentWillUnmount` together in class Components is equivalent to calling [`useEffect`](/reference/react/useEffect) in function components. In the rare cases where it's important for the code to run before browser paint, [`useLayoutEffect`](/reference/react/useLayoutEffect) is a closer match.
[See how to migrate.](#migrating-a-component-with-lifecycle-methods-from-a-class-to-a-function)
@@ -468,9 +468,9 @@ For many use cases, defining `componentDidMount`, `componentDidUpdate`, and `com
### `forceUpdate(callback?)` {/*forceupdate*/}
-Forces a component to re-render.
+Forces a Component to re-render.
-Usually, this is not necessary. If your component's [`render`](#render) method only reads from [`this.props`](#props), [`this.state`](#state), or [`this.context`,](#context) it will re-render automatically when you call [`setState`](#setstate) inside your component or one of its parents. However, if your component's `render` method reads directly from an external data source, you have to tell React to update the user interface when that data source changes. That's what `forceUpdate` lets you do.
+Usually, this is not necessary. If your component's [`render`](#render) method only reads from [`this.props`](#props), [`this.state`](#state), or [`this.context`,](#context) it will re-render automatically when you call [`setState`](#setstate) inside your Component or one of its parents. However, if your component's `render` method reads directly from an external data source, you have to tell React to update the user interface when that data source changes. That's what `forceUpdate` lets you do.
Try to avoid all uses of `forceUpdate` and only read from `this.props` and `this.state` in `render`.
@@ -488,7 +488,7 @@ Try to avoid all uses of `forceUpdate` and only read from `this.props` and `this
-Reading an external data source and forcing class components to re-render in response to its changes with `forceUpdate` has been superseded by [`useSyncExternalStore`](/reference/react/useSyncExternalStore) in function components.
+Reading an external data source and forcing class Components to re-render in response to its changes with `forceUpdate` has been superseded by [`useSyncExternalStore`](/reference/react/useSyncExternalStore) in function components.
@@ -508,7 +508,7 @@ Lets you specify the values for the [legacy context](https://reactjs.org/docs/le
### `getSnapshotBeforeUpdate(prevProps, prevState)` {/*getsnapshotbeforeupdate*/}
-If you implement `getSnapshotBeforeUpdate`, React will call it immediately before React updates the DOM. It enables your component to capture some information from the DOM (e.g. scroll position) before it is potentially changed. Any value returned by this lifecycle method will be passed as a parameter to [`componentDidUpdate`.](#componentdidupdate)
+If you implement `getSnapshotBeforeUpdate`, React will call it immediately before React updates the DOM. It enables your Component to capture some information from the DOM (e.g. scroll position) before it is potentially changed. Any value returned by this lifecycle method will be passed as a parameter to [`componentDidUpdate`.](#componentdidupdate)
For example, you can use it in a UI like a chat thread that needs to preserve its scroll position during updates:
@@ -639,7 +639,7 @@ class Form extends Component {
}
```
-`setState` enqueues changes to the component state. It tells React that this component and its children need to re-render with the new state. This is the main way you'll update the user interface in response to interactions.
+`setState` enqueues changes to the Component state. It tells React that this Component and its children need to re-render with the new state. This is the main way you'll update the user interface in response to interactions.
@@ -687,13 +687,13 @@ You don't have to do this, but it's handy if you want to update state multiple t
#### Caveats {/*setstate-caveats*/}
-- Think of `setState` as a *request* rather than an immediate command to update the component. When multiple components update their state in response to an event, React will batch their updates and re-render them together in a single pass at the end of the event. In the rare case that you need to force a particular state update to be applied synchronously, you may wrap it in [`flushSync`,](/reference/react-dom/flushSync) but this may hurt performance.
+- Think of `setState` as a *request* rather than an immediate command to update the component. When multiple Components update their state in response to an event, React will batch their updates and re-render them together in a single pass at the end of the event. In the rare case that you need to force a particular state update to be applied synchronously, you may wrap it in [`flushSync`,](/reference/react-dom/flushSync) but this may hurt performance.
- `setState` does not update `this.state` immediately. This makes reading `this.state` right after calling `setState` a potential pitfall. Instead, use [`componentDidUpdate`](#componentdidupdate) or the setState `callback` argument, either of which are guaranteed to fire after the update has been applied. If you need to set the state based on the previous state, you can pass a function to `nextState` as described above.
-Calling `setState` in class components is similar to calling a [`set` function](/reference/react/useState#setstate) in function components.
+Calling `setState` in class Components is similar to calling a [`set` function](/reference/react/useState#setstate) in function components.
[See how to migrate.](#migrating-a-component-with-state-from-a-class-to-a-function)
@@ -736,31 +736,31 @@ React calls `shouldComponentUpdate` before rendering when new props or state are
#### Parameters {/*shouldcomponentupdate-parameters*/}
-- `nextProps`: The next props that the component is about to render with. Compare `nextProps` to [`this.props`](#props) to determine what changed.
-- `nextState`: The next state that the component is about to render with. Compare `nextState` to [`this.state`](#props) to determine what changed.
-- `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) (modern) or [`static contextTypes`](#static-contexttypes) (legacy).
+- `nextProps`: The next props that the Component is about to render with. Compare `nextProps` to [`this.props`](#props) to determine what changed.
+- `nextState`: The next state that the Component is about to render with. Compare `nextState` to [`this.state`](#props) to determine what changed.
+- `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) (modern) or [`static contextTypes`](#static-contexttypes) (legacy).
#### Returns {/*shouldcomponentupdate-returns*/}
-Return `true` if you want the component to re-render. That's the default behavior.
+Return `true` if you want the Component to re-render. That's the default behavior.
Return `false` to tell React that re-rendering can be skipped.
#### Caveats {/*shouldcomponentupdate-caveats*/}
-- This method *only* exists as a performance optimization. If your component breaks without it, fix that first.
+- This method *only* exists as a performance optimization. If your Component breaks without it, fix that first.
- Consider using [`PureComponent`](/reference/react/PureComponent) instead of writing `shouldComponentUpdate` by hand. `PureComponent` shallowly compares props and state, and reduces the chance that you'll skip a necessary update.
- We do not recommend doing deep equality checks or using `JSON.stringify` in `shouldComponentUpdate`. It makes performance unpredictable and dependent on the data structure of every prop and state. In the best case, you risk introducing multi-second stalls to your application, and in the worst case you risk crashing it.
-- Returning `false` does not prevent child components from re-rendering when *their* state changes.
+- Returning `false` does not prevent child Components from re-rendering when *their* state changes.
-- Returning `false` does not *guarantee* that the component will not re-render. React will use the return value as a hint but it may still choose to re-render your component if it makes sense to do for other reasons.
+- Returning `false` does not *guarantee* that the Component will not re-render. React will use the return value as a hint but it may still choose to re-render your Component if it makes sense to do for other reasons.
-Optimizing class components with `shouldComponentUpdate` is similar to optimizing function components with [`memo`.](/reference/react/memo) Function components also offer more granular optimization with [`useMemo`.](/reference/react/useMemo)
+Optimizing class Components with `shouldComponentUpdate` is similar to optimizing function Components with [`memo`.](/reference/react/memo) Function Components also offer more granular optimization with [`useMemo`.](/reference/react/useMemo)
@@ -785,15 +785,15 @@ If you define `UNSAFE_componentWillMount`, React will call it immediately after
#### Caveats {/*unsafe_componentwillmount-caveats*/}
-- `UNSAFE_componentWillMount` will not get called if the component implements [`static getDerivedStateFromProps`](#static-getderivedstatefromprops) or [`getSnapshotBeforeUpdate`.](#getsnapshotbeforeupdate)
+- `UNSAFE_componentWillMount` will not get called if the Component implements [`static getDerivedStateFromProps`](#static-getderivedstatefromprops) or [`getSnapshotBeforeUpdate`.](#getsnapshotbeforeupdate)
-- Despite its naming, `UNSAFE_componentWillMount` does not guarantee that the component *will* get mounted if your app uses modern React features like [`Suspense`.](/reference/react/Suspense) If a render attempt is suspended (for example, because the code for some child component has not loaded yet), React will throw the in-progress tree away and attempt to construct the component from scratch during the next attempt. This is why this method is "unsafe". Code that relies on mounting (like adding a subscription) should go into [`componentDidMount`.](#componentdidmount)
+- Despite its naming, `UNSAFE_componentWillMount` does not guarantee that the Component *will* get mounted if your app uses modern React features like [`Suspense`.](/reference/react/Suspense) If a render attempt is suspended (for example, because the code for some child Component has not loaded yet), React will throw the in-progress tree away and attempt to construct the Component from scratch during the next attempt. This is why this method is "unsafe". Code that relies on mounting (like adding a subscription) should go into [`componentDidMount`.](#componentdidmount)
- `UNSAFE_componentWillMount` is the only lifecycle method that runs during [server rendering.](/reference/react-dom/server) For all practical purposes, it is identical to [`constructor`,](#constructor) so you should use the `constructor` for this type of logic instead.
-Calling [`setState`](#setstate) inside `UNSAFE_componentWillMount` in a class component to initialize state is equivalent to passing that state as the initial state to [`useState`](/reference/react/useState) in a function component.
+Calling [`setState`](#setstate) inside `UNSAFE_componentWillMount` in a class Component to initialize state is equivalent to passing that state as the initial state to [`useState`](/reference/react/useState) in a function component.
@@ -801,19 +801,19 @@ Calling [`setState`](#setstate) inside `UNSAFE_componentWillMount` in a class co
### `UNSAFE_componentWillReceiveProps(nextProps, nextContext)` {/*unsafe_componentwillreceiveprops*/}
-If you define `UNSAFE_componentWillReceiveProps`, React will call it when the component receives new props. It only exists for historical reasons and should not be used in any new code. Instead, use one of the alternatives:
+If you define `UNSAFE_componentWillReceiveProps`, React will call it when the Component receives new props. It only exists for historical reasons and should not be used in any new code. Instead, use one of the alternatives:
- If you need to **run a side effect** (for example, fetch data, run an animation, or reinitialize a subscription) in response to prop changes, move that logic to [`componentDidUpdate`](#componentdidupdate) instead.
- If you need to **avoid re-computing some data only when a prop changes,** use a [memoization helper](https://legacy.reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html#what-about-memoization) instead.
-- If you need to **"reset" some state when a prop changes,** consider either making a component [fully controlled](https://legacy.reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html#recommendation-fully-controlled-component) or [fully uncontrolled with a key](https://legacy.reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html#recommendation-fully-uncontrolled-component-with-a-key) instead.
+- If you need to **"reset" some state when a prop changes,** consider either making a Component [fully controlled](https://legacy.reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html#recommendation-fully-controlled-component) or [fully uncontrolled with a key](https://legacy.reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html#recommendation-fully-uncontrolled-component-with-a-key) instead.
- If you need to **"adjust" some state when a prop changes,** check whether you can compute all the necessary information from props alone during rendering. If you can't, use [`static getDerivedStateFromProps`](/reference/react/Component#static-getderivedstatefromprops) instead.
[See examples of migrating away from unsafe lifecycles.](https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props)
#### Parameters {/*unsafe_componentwillreceiveprops-parameters*/}
-- `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.
-- `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) (modern) or [`static contextTypes`](#static-contexttypes) (legacy).
+- `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.
+- `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) (modern) or [`static contextTypes`](#static-contexttypes) (legacy).
#### Returns {/*unsafe_componentwillreceiveprops-returns*/}
@@ -821,17 +821,17 @@ If you define `UNSAFE_componentWillReceiveProps`, React will call it when the co
#### Caveats {/*unsafe_componentwillreceiveprops-caveats*/}
-- `UNSAFE_componentWillReceiveProps` will not get called if the component implements [`static getDerivedStateFromProps`](#static-getderivedstatefromprops) or [`getSnapshotBeforeUpdate`.](#getsnapshotbeforeupdate)
+- `UNSAFE_componentWillReceiveProps` will not get called if the Component implements [`static getDerivedStateFromProps`](#static-getderivedstatefromprops) or [`getSnapshotBeforeUpdate`.](#getsnapshotbeforeupdate)
-- Despite its naming, `UNSAFE_componentWillReceiveProps` does not guarantee that the component *will* receive those props if your app uses modern React features like [`Suspense`.](/reference/react/Suspense) If a render attempt is suspended (for example, because the code for some child component has not loaded yet), React will throw the in-progress tree away and attempt to construct the component from scratch during the next attempt. By the time of the next render attempt, the props might be different. This is why this method is "unsafe". Code that should run only for committed updates (like resetting a subscription) should go into [`componentDidUpdate`.](#componentdidupdate)
+- Despite its naming, `UNSAFE_componentWillReceiveProps` does not guarantee that the Component *will* receive those props if your app uses modern React features like [`Suspense`.](/reference/react/Suspense) If a render attempt is suspended (for example, because the code for some child Component has not loaded yet), React will throw the in-progress tree away and attempt to construct the Component from scratch during the next attempt. By the time of the next render attempt, the props might be different. This is why this method is "unsafe". Code that should run only for committed updates (like resetting a subscription) should go into [`componentDidUpdate`.](#componentdidupdate)
-- `UNSAFE_componentWillReceiveProps` does not mean that the component has received *different* props than the last time. You need to compare `nextProps` and `this.props` yourself to check if something changed.
+- `UNSAFE_componentWillReceiveProps` does not mean that the Component has received *different* props than the last time. You need to compare `nextProps` and `this.props` yourself to check if something changed.
- React doesn't call `UNSAFE_componentWillReceiveProps` with initial props during mounting. It only calls this method if some of component's props are going to be updated. For example, calling [`setState`](#setstate) doesn't generally trigger `UNSAFE_componentWillReceiveProps` inside the same component.
-Calling [`setState`](#setstate) inside `UNSAFE_componentWillReceiveProps` in a class component to "adjust" state is equivalent to [calling the `set` function from `useState` during rendering](/reference/react/useState#storing-information-from-previous-renders) in a function component.
+Calling [`setState`](#setstate) inside `UNSAFE_componentWillReceiveProps` in a class Component to "adjust" state is equivalent to [calling the `set` function from `useState` during rendering](/reference/react/useState#storing-information-from-previous-renders) in a function component.
@@ -849,8 +849,8 @@ If you define `UNSAFE_componentWillUpdate`, React will call it before rendering
#### Parameters {/*unsafe_componentwillupdate-parameters*/}
-- `nextProps`: The next props that the component is about to render with. Compare `nextProps` to [`this.props`](#props) to determine what changed.
-- `nextState`: The next state that the component is about to render with. Compare `nextState` to [`this.state`](#state) to determine what changed.
+- `nextProps`: The next props that the Component is about to render with. Compare `nextProps` to [`this.props`](#props) to determine what changed.
+- `nextState`: The next state that the Component is about to render with. Compare `nextState` to [`this.state`](#state) to determine what changed.
#### Returns {/*unsafe_componentwillupdate-returns*/}
@@ -860,13 +860,13 @@ If you define `UNSAFE_componentWillUpdate`, React will call it before rendering
- `UNSAFE_componentWillUpdate` will not get called if [`shouldComponentUpdate`](#shouldcomponentupdate) is defined and returns `false`.
-- `UNSAFE_componentWillUpdate` will not get called if the component implements [`static getDerivedStateFromProps`](#static-getderivedstatefromprops) or [`getSnapshotBeforeUpdate`.](#getsnapshotbeforeupdate)
+- `UNSAFE_componentWillUpdate` will not get called if the Component implements [`static getDerivedStateFromProps`](#static-getderivedstatefromprops) or [`getSnapshotBeforeUpdate`.](#getsnapshotbeforeupdate)
- It's not supported to call [`setState`](#setstate) (or any method that leads to `setState` being called, like dispatching a Redux action) during `componentWillUpdate`.
-- Despite its naming, `UNSAFE_componentWillUpdate` does not guarantee that the component *will* update if your app uses modern React features like [`Suspense`.](/reference/react/Suspense) If a render attempt is suspended (for example, because the code for some child component has not loaded yet), React will throw the in-progress tree away and attempt to construct the component from scratch during the next attempt. By the time of the next render attempt, the props and state might be different. This is why this method is "unsafe". Code that should run only for committed updates (like resetting a subscription) should go into [`componentDidUpdate`.](#componentdidupdate)
+- Despite its naming, `UNSAFE_componentWillUpdate` does not guarantee that the Component *will* update if your app uses modern React features like [`Suspense`.](/reference/react/Suspense) If a render attempt is suspended (for example, because the code for some child Component has not loaded yet), React will throw the in-progress tree away and attempt to construct the Component from scratch during the next attempt. By the time of the next render attempt, the props and state might be different. This is why this method is "unsafe". Code that should run only for committed updates (like resetting a subscription) should go into [`componentDidUpdate`.](#componentdidupdate)
-- `UNSAFE_componentWillUpdate` does not mean that the component has received *different* props or state than the last time. You need to compare `nextProps` with `this.props` and `nextState` with `this.state` yourself to check if something changed.
+- `UNSAFE_componentWillUpdate` does not mean that the Component has received *different* props or state than the last time. You need to compare `nextProps` with `this.props` and `nextState` with `this.state` yourself to check if something changed.
- React doesn't call `UNSAFE_componentWillUpdate` with initial props and state during mounting.
@@ -924,7 +924,7 @@ class Button extends Component {
-Reading `this.context` in class components is equivalent to [`useContext`](/reference/react/useContext) in function components.
+Reading `this.context` in class Components is equivalent to [`useContext`](/reference/react/useContext) in function components.
[See how to migrate.](#migrating-a-component-with-context-from-a-class-to-a-function)
@@ -970,7 +970,7 @@ If the `color` prop is not provided or is `undefined`, it will be set by default
-Defining `defaultProps` in class components is similar to using [default values](/learn/passing-props-to-a-component#specifying-a-default-value-for-a-prop) in function components.
+Defining `defaultProps` in class Components is similar to using [default values](/learn/passing-props-to-a-component#specifying-a-default-value-for-a-prop) in function components.
@@ -1006,9 +1006,9 @@ We recommend using [TypeScript](https://www.typescriptlang.org/) instead of chec
### `static getDerivedStateFromError(error)` {/*static-getderivedstatefromerror*/}
-If you define `static getDerivedStateFromError`, React will call it when a child component (including distant children) throws an error during rendering. This lets you display an error message instead of clearing the UI.
+If you define `static getDerivedStateFromError`, React will call it when a child Component (including distant children) throws an error during rendering. This lets you display an error message instead of clearing the UI.
-Typically, it is used together with [`componentDidCatch`](#componentdidcatch) which lets you send the error report to some analytics service. A component with these methods is called an *error boundary.*
+Typically, it is used together with [`componentDidCatch`](#componentdidcatch) which lets you send the error report to some analytics service. A Component with these methods is called an *error boundary.*
[See an example.](#catching-rendering-errors-with-an-error-boundary)
@@ -1018,7 +1018,7 @@ Typically, it is used together with [`componentDidCatch`](#componentdidcatch) wh
#### Returns {/*static-getderivedstatefromerror-returns*/}
-`static getDerivedStateFromError` should return the state telling the component to display the error message.
+`static getDerivedStateFromError` should return the state telling the Component to display the error message.
#### Caveats {/*static-getderivedstatefromerror-caveats*/}
@@ -1026,7 +1026,7 @@ Typically, it is used together with [`componentDidCatch`](#componentdidcatch) wh
-There is no direct equivalent for `static getDerivedStateFromError` in function components yet. If you'd like to avoid creating class components, write a single `ErrorBoundary` component like above and use it throughout your app. Alternatively, use the [`react-error-boundary`](https://github.com/bvaughn/react-error-boundary) package which does that.
+There is no direct equivalent for `static getDerivedStateFromError` in function Components yet. If you'd like to avoid creating class components, write a single `ErrorBoundary` Component like above and use it throughout your app. Alternatively, use the [`react-error-boundary`](https://github.com/bvaughn/react-error-boundary) package which does that.
@@ -1036,7 +1036,7 @@ There is no direct equivalent for `static getDerivedStateFromError` in function
If you define `static getDerivedStateFromProps`, React will call it right before calling [`render`,](#render) both on the initial mount and on subsequent updates. It should return an object to update the state, or `null` to update nothing.
-This method exists for [rare use cases](https://legacy.reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html#when-to-use-derived-state) where the state depends on changes in props over time. For example, this `Form` component resets the `email` state when the `userID` prop changes:
+This method exists for [rare use cases](https://legacy.reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html#when-to-use-derived-state) where the state depends on changes in props over time. For example, this `Form` Component resets the `email` state when the `userID` prop changes:
```js {7-18}
class Form extends Component {
@@ -1066,18 +1066,18 @@ Note that this pattern requires you to keep a previous value of the prop (like `
-Deriving state leads to verbose code and makes your components difficult to think about. [Make sure you're familiar with simpler alternatives:](https://legacy.reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html)
+Deriving state leads to verbose code and makes your Components difficult to think about. [Make sure you're familiar with simpler alternatives:](https://legacy.reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html)
- If you need to **perform a side effect** (for example, data fetching or an animation) in response to a change in props, use [`componentDidUpdate`](#componentdidupdate) method instead.
- If you want to **re-compute some data only when a prop changes,** [use a memoization helper instead.](https://legacy.reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html#what-about-memoization)
-- If you want to **"reset" some state when a prop changes,** consider either making a component [fully controlled](https://legacy.reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html#recommendation-fully-controlled-component) or [fully uncontrolled with a key](https://legacy.reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html#recommendation-fully-uncontrolled-component-with-a-key) instead.
+- If you want to **"reset" some state when a prop changes,** consider either making a Component [fully controlled](https://legacy.reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html#recommendation-fully-controlled-component) or [fully uncontrolled with a key](https://legacy.reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html#recommendation-fully-uncontrolled-component-with-a-key) instead.
#### Parameters {/*static-getderivedstatefromprops-parameters*/}
-- `props`: The next props that the component is about to render with.
-- `state`: The next state that the component is about to render with.
+- `props`: The next props that the Component is about to render with.
+- `state`: The next state that the Component is about to render with.
#### Returns {/*static-getderivedstatefromprops-returns*/}
@@ -1087,11 +1087,11 @@ Deriving state leads to verbose code and makes your components difficult to thin
- This method is fired on *every* render, regardless of the cause. This is different from [`UNSAFE_componentWillReceiveProps`](#unsafe_cmoponentwillreceiveprops), which only fires when the parent causes a re-render and not as a result of a local `setState`.
-- This method doesn't have access to the component instance. If you'd like, you can reuse some code between `static getDerivedStateFromProps` and the other class methods by extracting pure functions of the component props and state outside the class definition.
+- This method doesn't have access to the Component instance. If you'd like, you can reuse some code between `static getDerivedStateFromProps` and the other class methods by extracting pure functions of the Component props and state outside the class definition.
-Implementing `static getDerivedStateFromProps` in a class component is equivalent to [calling the `set` function from `useState` during rendering](/reference/react/useState#storing-information-from-previous-renders) in a function component.
+Implementing `static getDerivedStateFromProps` in a class Component is equivalent to [calling the `set` function from `useState` during rendering](/reference/react/useState#storing-information-from-previous-renders) in a function component.
@@ -1099,9 +1099,9 @@ Implementing `static getDerivedStateFromProps` in a class component is equivalen
## Usage {/*usage*/}
-### Defining a class component {/*defining-a-class-component*/}
+### Defining a class Component {/*defining-a-class-component*/}
-To define a React component as a class, extend the built-in `Component` class and define a [`render` method:](#render)
+To define a React Component as a class, extend the built-in `Component` class and define a [`render` method:](#render)
```js
import { Component } from 'react';
@@ -1115,7 +1115,7 @@ class Greeting extends Component {
React will call your [`render`](#render) method whenever it needs to figure out what to display on the screen. Usually, you will return some [JSX](/learn/writing-markup-with-jsx) from it. Your `render` method should be a [pure function:](https://en.wikipedia.org/wiki/Pure_function) it should only calculate the JSX.
-Similarly to [function components,](/learn/your-first-component#defining-a-component) a class component can [receive information by props](/learn/your-first-component#defining-a-component) from its parent component. However, the syntax for reading props is different. For example, if the parent component renders ``, then you can read the `name` prop from [`this.props`](#props), like `this.props.name`:
+Similarly to [function components,](/learn/your-first-component#defining-a-component) a class Component can [receive information by props](/learn/your-first-component#defining-a-component) from its parent component. However, the syntax for reading props is different. For example, if the parent Component renders ``, then you can read the `name` prop from [`this.props`](#props), like `this.props.name`:
@@ -1145,13 +1145,13 @@ Note that Hooks (functions starting with `use`, like [`useState`](/reference/rea
-We recommend defining components as functions instead of classes. [See how to migrate.](#migrating-a-simple-component-from-a-class-to-a-function)
+We recommend defining Components as functions instead of classes. [See how to migrate.](#migrating-a-simple-component-from-a-class-to-a-function)
---
-### Adding state to a class component {/*adding-state-to-a-class-component*/}
+### Adding state to a class Component {/*adding-state-to-a-class-component*/}
To add [state](/learn/state-a-components-memory) to a class, assign an object to a property called [`state`](#state). To update state, call [`this.setState`](#setstate).
@@ -1203,21 +1203,21 @@ button { display: block; margin-top: 10px; }
-We recommend defining components as functions instead of classes. [See how to migrate.](#migrating-a-component-with-state-from-a-class-to-a-function)
+We recommend defining Components as functions instead of classes. [See how to migrate.](#migrating-a-component-with-state-from-a-class-to-a-function)
---
-### Adding lifecycle methods to a class component {/*adding-lifecycle-methods-to-a-class-component*/}
+### Adding lifecycle methods to a class Component {/*adding-lifecycle-methods-to-a-class-component*/}
There are a few special methods you can define on your class.
-If you define the [`componentDidMount`](#componentdidmount) method, React will call it when your component is added *(mounted)* to the screen. React will call [`componentDidUpdate`](#componentdidupdate) after your component re-renders due to changed props or state. React will call [`componentWillUnmount`](#componentwillunmount) after your component has been removed *(unmounted)* from the screen.
+If you define the [`componentDidMount`](#componentdidmount) method, React will call it when your Component is added *(mounted)* to the screen. React will call [`componentDidUpdate`](#componentdidupdate) after your Component re-renders due to changed props or state. React will call [`componentWillUnmount`](#componentwillunmount) after your Component has been removed *(unmounted)* from the screen.
If you implement `componentDidMount`, you usually need to implement all three lifecycles to avoid bugs. For example, if `componentDidMount` reads some state or props, you also have to implement `componentDidUpdate` to handle their changes, and `componentWillUnmount` to clean up whatever `componentDidMount` was doing.
-For example, this `ChatRoom` component keeps a chat connection synchronized with props and state:
+For example, this `ChatRoom` Component keeps a chat connection synchronized with props and state:
@@ -1337,7 +1337,7 @@ Note that in development when [Strict Mode](/reference/react/StrictMode) is on,
-We recommend defining components as functions instead of classes. [See how to migrate.](#migrating-a-component-with-lifecycle-methods-from-a-class-to-a-function)
+We recommend defining Components as functions instead of classes. [See how to migrate.](#migrating-a-component-with-lifecycle-methods-from-a-class-to-a-function)
@@ -1345,7 +1345,7 @@ We recommend defining components as functions instead of classes. [See how to mi
### Catching rendering errors with an error boundary {/*catching-rendering-errors-with-an-error-boundary*/}
-By default, if your application throws an error during rendering, React will remove its UI from the screen. To prevent this, you can wrap a part of your UI into an *error boundary*. An error boundary is a special component that lets you display some fallback UI instead of the part that crashed--for example, an error message.
+By default, if your application throws an error during rendering, React will remove its UI from the screen. To prevent this, you can wrap a part of your UI into an *error boundary*. An error boundary is a special Component that lets you display some fallback UI instead of the part that crashed--for example, an error message.
To implement an error boundary component, you need to provide [`static getDerivedStateFromError`](#static-getderivedstatefromerror) which lets you update state in response to an error and display an error message to the user. You can also optionally implement [`componentDidCatch`](#componentdidcatch) to add some extra logic, for example, to log the error to an analytics service.
@@ -1381,7 +1381,7 @@ class ErrorBoundary extends React.Component {
}
```
-Then you can wrap a part of your component tree with it:
+Then you can wrap a part of your Component tree with it:
```js {1,3}
Something went wrong}>
@@ -1389,9 +1389,9 @@ Then you can wrap a part of your component tree with it:
```
-If `Profile` or its child component throws an error, `ErrorBoundary` will "catch" that error, display a fallback UI with the error message you've provided, and send a production error report to your error reporting service.
+If `Profile` or its child Component throws an error, `ErrorBoundary` will "catch" that error, display a fallback UI with the error message you've provided, and send a production error report to your error reporting service.
-You don't need to wrap every component into a separate error boundary. When you think about the [granularity of error boundaries,](https://www.brandondail.com/posts/fault-tolerance-react) consider where it makes sense to display an error message. For example, in a messaging app, it makes sense to place an error boundary around the list of conversations. It also makes sense to place one around every individual message. However, it wouldn't make sense to place a boundary around every avatar.
+You don't need to wrap every Component into a separate error boundary. When you think about the [granularity of error boundaries,](https://www.brandondail.com/posts/fault-tolerance-react) consider where it makes sense to display an error message. For example, in a messaging app, it makes sense to place an error boundary around the list of conversations. It also makes sense to place one around every individual message. However, it wouldn't make sense to place a boundary around every avatar.
@@ -1403,11 +1403,11 @@ There is currently no way to write an error boundary as a function component. Ho
## Alternatives {/*alternatives*/}
-### Migrating a simple component from a class to a function {/*migrating-a-simple-component-from-a-class-to-a-function*/}
+### Migrating a simple Component from a class to a function {/*migrating-a-simple-component-from-a-class-to-a-function*/}
-Typically, you will [define components as functions](/learn/your-first-component#defining-a-component) instead.
+Typically, you will [define Components as functions](/learn/your-first-component#defining-a-component) instead.
-For example, suppose you're converting this `Greeting` class component to a function:
+For example, suppose you're converting this `Greeting` class Component to a function:
@@ -1473,9 +1473,9 @@ export default function App() {
---
-### Migrating a component with state from a class to a function {/*migrating-a-component-with-state-from-a-class-to-a-function*/}
+### Migrating a Component with state from a class to a function {/*migrating-a-component-with-state-from-a-class-to-a-function*/}
-Suppose you're converting this `Counter` class component to a function:
+Suppose you're converting this `Counter` class Component to a function:
@@ -1595,9 +1595,9 @@ button { display: block; margin-top: 10px; }
---
-### Migrating a component with lifecycle methods from a class to a function {/*migrating-a-component-with-lifecycle-methods-from-a-class-to-a-function*/}
+### Migrating a Component with lifecycle methods from a class to a function {/*migrating-a-component-with-lifecycle-methods-from-a-class-to-a-function*/}
-Suppose you're converting this `ChatRoom` class component with lifecycle methods to a function:
+Suppose you're converting this `ChatRoom` class Component with lifecycle methods to a function:
@@ -1717,7 +1717,7 @@ First, verify that your [`componentWillUnmount`](#componentwillunmount) does the
Next, verify that your [`componentDidUpdate`](#componentdidupdate) method handles changes to any props and state you're using in `componentDidMount`. In the above example, `componentDidMount` calls `setupConnection` which reads `this.state.serverUrl` and `this.props.roomId`. This is why `componentDidUpdate` checks whether `this.state.serverUrl` and `this.props.roomId` have changed, and resets the connection if they did. If your `componentDidUpdate` logic is missing or doesn't handle changes to all relevant props and state, fix that first.
-In the above example, the logic inside the lifecycle methods connects the component to a system outside of React (a chat server). To connect a component to an external system, [describe this logic as a single Effect:](/reference/react/useEffect#connecting-to-an-external-system)
+In the above example, the logic inside the lifecycle methods connects the Component to a system outside of React (a chat server). To connect a Component to an external system, [describe this logic as a single Effect:](/reference/react/useEffect#connecting-to-an-external-system)
```js {6-12}
import { useState, useEffect } from 'react';
@@ -1824,15 +1824,15 @@ button { margin-left: 10px; }
-If your component does not synchronize with any external systems, [you might not need an Effect.](/learn/you-might-not-need-an-effect)
+If your Component does not synchronize with any external systems, [you might not need an Effect.](/learn/you-might-not-need-an-effect)
---
-### Migrating a component with context from a class to a function {/*migrating-a-component-with-context-from-a-class-to-a-function*/}
+### Migrating a Component with context from a class to a function {/*migrating-a-component-with-context-from-a-class-to-a-function*/}
-In this example, the `Panel` and `Button` class components read [context](/learn/passing-data-deeply-with-context) from [`this.context`:](#context)
+In this example, the `Panel` and `Button` class Components read [context](/learn/passing-data-deeply-with-context) from [`this.context`:](#context)
diff --git a/src/content/reference/react/Fragment.md b/src/content/reference/react/Fragment.md
index aa72b08a0ba..2bbb0463cf3 100644
--- a/src/content/reference/react/Fragment.md
+++ b/src/content/reference/react/Fragment.md
@@ -41,7 +41,7 @@ Wrap elements in `` to group them together in situations where you nee
### Returning multiple elements {/*returning-multiple-elements*/}
-Use `Fragment`, or the equivalent `<>...>` syntax, to group multiple elements together. You can use it to put multiple elements in any place where a single element can go. For example, a component can only return one element, but by using a Fragment you can group multiple elements together and then return them as a group:
+Use `Fragment`, or the equivalent `<>...>` syntax, to group multiple elements together. You can use it to put multiple elements in any place where a single element can go. For example, a Component can only return one element, but by using a Fragment you can group multiple elements together and then return them as a group:
```js {3,6}
function Post() {
diff --git a/src/content/reference/react/Profiler.md b/src/content/reference/react/Profiler.md
index 188b2d1b2bd..bc5416e7e7d 100644
--- a/src/content/reference/react/Profiler.md
+++ b/src/content/reference/react/Profiler.md
@@ -22,7 +22,7 @@ title:
### `` {/*profiler*/}
-Wrap a component tree in a `` to measure its rendering performance.
+Wrap a Component tree in a `` to measure its rendering performance.
```js
@@ -33,7 +33,7 @@ Wrap a component tree in a `` to measure its rendering performance.
#### Props {/*props*/}
* `id`: A string identifying the part of the UI you are measuring.
-* `onRender`: An [`onRender` callback](#onrender-callback) that React calls every time components within the profiled tree update. It receives information about what was rendered and how much time it took.
+* `onRender`: An [`onRender` callback](#onrender-callback) that React calls every time Components within the profiled tree update. It receives information about what was rendered and how much time it took.
#### Caveats {/*caveats*/}
@@ -56,7 +56,7 @@ function onRender(id, phase, actualDuration, baseDuration, startTime, commitTime
* `id`: The string `id` prop of the `` tree that has just committed. This lets you identify which part of the tree was committed if you are using multiple profilers.
* `phase`: `"mount"`, `"update"` or `"nested-update"`. This lets you know whether the tree has just been mounted for the first time or re-rendered due to a change in props, state, or Hooks.
* `actualDuration`: The number of milliseconds spent rendering the `` and its descendants for the current update. This indicates how well the subtree makes use of memoization (e.g. [`memo`](/reference/react/memo) and [`useMemo`](/reference/react/useMemo)). Ideally this value should decrease significantly after the initial mount as many of the descendants will only need to re-render if their specific props change.
-* `baseDuration`: The number of milliseconds estimating how much time it would take to re-render the entire `` subtree without any optimizations. It is calculated by summing up the most recent render durations of each component in the tree. This value estimates a worst-case cost of rendering (e.g. the initial mount or a tree with no memoization). Compare `actualDuration` against it to see if memoization is working.
+* `baseDuration`: The number of milliseconds estimating how much time it would take to re-render the entire `` subtree without any optimizations. It is calculated by summing up the most recent render durations of each Component in the tree. This value estimates a worst-case cost of rendering (e.g. the initial mount or a tree with no memoization). Compare `actualDuration` against it to see if memoization is working.
* `startTime`: A numeric timestamp for when React began rendering the current update.
* `commitTime`: A numeric timestamp for when React committed the current update. This value is shared between all profilers in a commit, enabling them to be grouped if desirable.
@@ -66,7 +66,7 @@ function onRender(id, phase, actualDuration, baseDuration, startTime, commitTime
### Measuring rendering performance programmatically {/*measuring-rendering-performance-programmatically*/}
-Wrap the `` component around a React tree to measure its rendering performance.
+Wrap the `` Component around a React tree to measure its rendering performance.
```js {2,4}
@@ -77,7 +77,7 @@ Wrap the `` component around a React tree to measure its rendering per
```
-It requires two props: an `id` (string) and an `onRender` callback (function) which React calls any time a component within the tree "commits" an update.
+It requires two props: an `id` (string) and an `onRender` callback (function) which React calls any time a Component within the tree "commits" an update.
@@ -95,7 +95,7 @@ Profiling adds some additional overhead, so **it is disabled in the production b
### Measuring different parts of the application {/*measuring-different-parts-of-the-application*/}
-You can use multiple `` components to measure different parts of your application:
+You can use multiple `` Components to measure different parts of your application:
```js {5,7}
diff --git a/src/content/reference/react/PureComponent.md b/src/content/reference/react/PureComponent.md
index 3e2d074e10d..40ad298ebe3 100644
--- a/src/content/reference/react/PureComponent.md
+++ b/src/content/reference/react/PureComponent.md
@@ -4,13 +4,13 @@ title: PureComponent
-We recommend defining components as functions instead of classes. [See how to migrate.](#alternatives)
+We recommend defining Components as functions instead of classes. [See how to migrate.](#alternatives)
-`PureComponent` is similar to [`Component`](/reference/react/Component) but it skips re-renders for same props and state. Class components are still supported by React, but we don't recommend using them in new code.
+`PureComponent` is similar to [`Component`](/reference/react/Component) but it skips re-renders for same props and state. Class Components are still supported by React, but we don't recommend using them in new code.
```js
class Greeting extends PureComponent {
@@ -30,7 +30,7 @@ class Greeting extends PureComponent {
### `PureComponent` {/*purecomponent*/}
-To skip re-rendering a class component for same props and state, extend `PureComponent` instead of [`Component`:](/reference/react/Component)
+To skip re-rendering a class Component for same props and state, extend `PureComponent` instead of [`Component`:](/reference/react/Component)
```js
import { PureComponent } from 'react';
@@ -51,9 +51,9 @@ class Greeting extends PureComponent {
## Usage {/*usage*/}
-### Skipping unnecessary re-renders for class components {/*skipping-unnecessary-re-renders-for-class-components*/}
+### Skipping unnecessary re-renders for class Components {/*skipping-unnecessary-re-renders-for-class-components*/}
-React normally re-renders a component whenever its parent re-renders. As an optimization, you can create a component that React will not re-render when its parent re-renders so long as its new props and state are the same as the old props and state. [Class components](/reference/react/Component) can opt into this behavior by extending `PureComponent`:
+React normally re-renders a Component whenever its parent re-renders. As an optimization, you can create a Component that React will not re-render when its parent re-renders so long as its new props and state are the same as the old props and state. [Class components](/reference/react/Component) can opt into this behavior by extending `PureComponent`:
```js {1}
class Greeting extends PureComponent {
@@ -63,9 +63,9 @@ class Greeting extends PureComponent {
}
```
-A React component should always have [pure rendering logic.](/learn/keeping-components-pure) This means that it must return the same output if its props, state, and context haven't changed. By using `PureComponent`, you are telling React that your component complies with this requirement, so React doesn't need to re-render as long as its props and state haven't changed. However, your component will still re-render if a context that it's using changes.
+A React Component should always have [pure rendering logic.](/learn/keeping-components-pure) This means that it must return the same output if its props, state, and context haven't changed. By using `PureComponent`, you are telling React that your Component complies with this requirement, so React doesn't need to re-render as long as its props and state haven't changed. However, your Component will still re-render if a context that it's using changes.
-In this example, notice that the `Greeting` component re-renders whenever `name` is changed (because that's one of its props), but not when `address` is changed (because it's not passed to `Greeting` as a prop):
+In this example, notice that the `Greeting` Component re-renders whenever `name` is changed (because that's one of its props), but not when `address` is changed (because it's not passed to `Greeting` as a prop):
@@ -109,7 +109,7 @@ label {
-We recommend defining components as functions instead of classes. [See how to migrate.](#alternatives)
+We recommend defining Components as functions instead of classes. [See how to migrate.](#alternatives)
@@ -117,9 +117,9 @@ We recommend defining components as functions instead of classes. [See how to mi
## Alternatives {/*alternatives*/}
-### Migrating from a `PureComponent` class component to a function {/*migrating-from-a-purecomponent-class-component-to-a-function*/}
+### Migrating from a `PureComponent` class Component to a function {/*migrating-from-a-purecomponent-class-component-to-a-function*/}
-We recommend using function components instead of [class components](/reference/react/Component) in new code. If you have some existing class components using `PureComponent`, here is how you can convert them. This is the original code:
+We recommend using function Components instead of [class components](/reference/react/Component) in new code. If you have some existing class Components using `PureComponent`, here is how you can convert them. This is the original code:
@@ -161,7 +161,7 @@ label {
-When you [convert this component from a class to a function,](/reference/react/Component#alternatives) wrap it in [`memo`:](/reference/react/memo)
+When you [convert this Component from a class to a function,](/reference/react/Component#alternatives) wrap it in [`memo`:](/reference/react/memo)
diff --git a/src/content/reference/react/StrictMode.md b/src/content/reference/react/StrictMode.md
index 92c6ba63af0..7df0cdf1734 100644
--- a/src/content/reference/react/StrictMode.md
+++ b/src/content/reference/react/StrictMode.md
@@ -5,7 +5,7 @@ title:
-`` lets you find common bugs in your components early during development.
+`` lets you find common bugs in your Components early during development.
```js
@@ -24,7 +24,7 @@ title:
### `` {/*strictmode*/}
-Use `StrictMode` to enable additional development behaviors and warnings for the component tree inside:
+Use `StrictMode` to enable additional development behaviors and warnings for the Component tree inside:
```js
import { StrictMode } from 'react';
@@ -42,9 +42,9 @@ root.render(
Strict Mode enables the following development-only behaviors:
-- Your components will [re-render an extra time](#fixing-bugs-found-by-double-rendering-in-development) to find bugs caused by impure rendering.
-- Your components will [re-run Effects an extra time](#fixing-bugs-found-by-re-running-effects-in-development) to find bugs caused by missing Effect cleanup.
-- Your components will [be checked for usage of deprecated APIs.](#fixing-deprecation-warnings-enabled-by-strict-mode)
+- Your Components will [re-render an extra time](#fixing-bugs-found-by-double-rendering-in-development) to find bugs caused by impure rendering.
+- Your Components will [re-run Effects an extra time](#fixing-bugs-found-by-re-running-effects-in-development) to find bugs caused by missing Effect cleanup.
+- Your Components will [be checked for usage of deprecated APIs.](#fixing-deprecation-warnings-enabled-by-strict-mode)
#### Props {/*props*/}
@@ -52,7 +52,7 @@ Strict Mode enables the following development-only behaviors:
#### Caveats {/*caveats*/}
-* There is no way to opt out of Strict Mode inside a tree wrapped in ``. This gives you confidence that all components inside `` are checked. If two teams working on a product disagree whether they find the checks valuable, they need to either reach consensus or move `` down in the tree.
+* There is no way to opt out of Strict Mode inside a tree wrapped in ``. This gives you confidence that all Components inside `` are checked. If two teams working on a product disagree whether they find the checks valuable, they need to either reach consensus or move `` down in the tree.
---
@@ -60,10 +60,10 @@ Strict Mode enables the following development-only behaviors:
### Enabling Strict Mode for entire app {/*enabling-strict-mode-for-entire-app*/}
-Strict Mode enables extra development-only checks for the entire component tree inside the `` component. These checks help you find common bugs in your components early in the development process.
+Strict Mode enables extra development-only checks for the entire Component tree inside the `` component. These checks help you find common bugs in your Components early in the development process.
-To enable Strict Mode for your entire app, wrap your root component with `` when you render it:
+To enable Strict Mode for your entire app, wrap your root Component with `` when you render it:
```js {6,8}
import { StrictMode } from 'react';
@@ -85,9 +85,9 @@ Although the Strict Mode checks **only run in development,** they help you find
Strict Mode enables the following checks in development:
-- Your components will [re-render an extra time](#fixing-bugs-found-by-double-rendering-in-development) to find bugs caused by impure rendering.
-- Your components will [re-run Effects an extra time](#fixing-bugs-found-by-re-running-effects-in-development) to find bugs caused by missing Effect cleanup.
-- Your components will [be checked for usage of deprecated APIs.](#fixing-deprecation-warnings-enabled-by-strict-mode)
+- Your Components will [re-render an extra time](#fixing-bugs-found-by-double-rendering-in-development) to find bugs caused by impure rendering.
+- Your Components will [re-run Effects an extra time](#fixing-bugs-found-by-re-running-effects-in-development) to find bugs caused by missing Effect cleanup.
+- Your Components will [be checked for usage of deprecated APIs.](#fixing-deprecation-warnings-enabled-by-strict-mode)
**All of these checks are development-only and do not impact the production build.**
@@ -118,25 +118,25 @@ function App() {
}
```
-In this example, Strict Mode checks will not run against the `Header` and `Footer` components. However, they will run on `Sidebar` and `Content`, as well as all of the components inside them, no matter how deep.
+In this example, Strict Mode checks will not run against the `Header` and `Footer` components. However, they will run on `Sidebar` and `Content`, as well as all of the Components inside them, no matter how deep.
---
### Fixing bugs found by double rendering in development {/*fixing-bugs-found-by-double-rendering-in-development*/}
-[React assumes that every component you write is a pure function.](/learn/keeping-components-pure) This means that React components you write must always return the same JSX given the same inputs (props, state, and context).
+[React assumes that every Component you write is a pure function.](/learn/keeping-components-pure) This means that React Components you write must always return the same JSX given the same inputs (props, state, and context).
Components breaking this rule behave unpredictably and cause bugs. To help you find accidentally impure code, Strict Mode calls some of your functions (only the ones that should be pure) **twice in development.** This includes:
-- Your component function body (only top-level logic, so this doesn't include code inside event handlers)
+- Your Component function body (only top-level logic, so this doesn't include code inside event handlers)
- Functions that you pass to [`useState`](/reference/react/useState), [`set` functions](/reference/react/useState#setstate), [`useMemo`](/reference/react/useMemo), or [`useReducer`](/reference/react/useReducer)
-- Some class component methods like [`constructor`](/reference/react/Component#constructor), [`render`](/reference/react/Component#render), [`shouldComponentUpdate`](/reference/react/Component#shouldcomponentupdate) ([see the whole list](https://reactjs.org/docs/strict-mode.html#detecting-unexpected-side-effects))
+- Some class Component methods like [`constructor`](/reference/react/Component#constructor), [`render`](/reference/react/Component#render), [`shouldComponentUpdate`](/reference/react/Component#shouldcomponentupdate) ([see the whole list](https://reactjs.org/docs/strict-mode.html#detecting-unexpected-side-effects))
If a function is pure, running it twice does not change its behavior because a pure function produces the same result every time. However, if a function is impure (for example, it mutates the data it receives), running it twice tends to be noticeable (that's what makes it impure!) This helps you spot and fix the bug early.
**Here is an example to illustrate how double rendering in Strict Mode helps you find bugs early.**
-This `StoryTray` component takes an array of `stories` and adds one last "Create Story" item at the end:
+This `StoryTray` Component takes an array of `stories` and adds one last "Create Story" item at the end:
@@ -216,7 +216,7 @@ li {
There is a mistake in the code above. However, it is easy to miss because the initial output appears correct.
-This mistake will become more noticeable if the `StoryTray` component re-renders multiple times. For example, let's make the `StoryTray` re-render with a different background color whenever you hover over it:
+This mistake will become more noticeable if the `StoryTray` Component re-renders multiple times. For example, let's make the `StoryTray` re-render with a different background color whenever you hover over it:
@@ -314,7 +314,7 @@ export default function StoryTray({ stories }) {
items.push({ id: 'create', label: 'Create Story' });
```
-This would [make the `StoryTray` function pure.](/learn/keeping-components-pure) Each time it is called, it would only modify a new copy of the array, and would not affect any external objects or variables. This solves the bug, but you had to make the component re-render more often before it became obvious that something is wrong with its behavior.
+This would [make the `StoryTray` function pure.](/learn/keeping-components-pure) Each time it is called, it would only modify a new copy of the array, and would not affect any external objects or variables. This solves the bug, but you had to make the Component re-render more often before it became obvious that something is wrong with its behavior.
**In the original example, the bug wasn't obvious. Now let's wrap the original (buggy) code in ``:**
@@ -399,7 +399,7 @@ li {
-**Strict Mode *always* calls your rendering function twice, so you can see the mistake right away** ("Create Story" appears twice). This lets you notice such mistakes early in the process. When you fix your component to render in Strict Mode, you *also* fix many possible future production bugs like the hover functionality from before:
+**Strict Mode *always* calls your rendering function twice, so you can see the mistake right away** ("Create Story" appears twice). This lets you notice such mistakes early in the process. When you fix your Component to render in Strict Mode, you *also* fix many possible future production bugs like the hover functionality from before:
@@ -493,7 +493,7 @@ li {
Without Strict Mode, it was easy to miss the bug until you added more re-renders. Strict Mode made the same bug appear right away. Strict Mode helps you find bugs before you push them to your team and to your users.
-[Read more about keeping components pure.](/learn/keeping-components-pure)
+[Read more about keeping Components pure.](/learn/keeping-components-pure)
@@ -507,13 +507,13 @@ If you have [React DevTools](/learn/react-developer-tools) installed, any `conso
Strict Mode can also help find bugs in [Effects.](/learn/synchronizing-with-effects)
-Every Effect has some setup code and may have some cleanup code. Normally, React calls setup when the component *mounts* (is added to the screen) and calls cleanup when the component *unmounts* (is removed from the screen). React then calls cleanup and setup again if its dependencies changed since the last render.
+Every Effect has some setup code and may have some cleanup code. Normally, React calls setup when the Component *mounts* (is added to the screen) and calls cleanup when the Component *unmounts* (is removed from the screen). React then calls cleanup and setup again if its dependencies changed since the last render.
When Strict Mode is on, React will also run **one extra setup+cleanup cycle in development for every Effect.** This may feel surprising, but it helps reveal subtle bugs that are hard to catch manually.
**Here is an example to illustrate how re-running Effects in Strict Mode helps you find bugs early.**
-Consider this example that connects a component to a chat:
+Consider this example that connects a Component to a chat:
@@ -828,7 +828,7 @@ Without Strict Mode, it was easy to miss that your Effect needed cleanup. By run
### Fixing deprecation warnings enabled by Strict Mode {/*fixing-deprecation-warnings-enabled-by-strict-mode*/}
-React warns if some component anywhere inside a `` tree uses one of these deprecated APIs:
+React warns if some Component anywhere inside a `` tree uses one of these deprecated APIs:
* [`findDOMNode`](/reference/react-dom/findDOMNode). [See alternatives.](https://reactjs.org/docs/strict-mode.html#warning-about-deprecated-finddomnode-usage)
* `UNSAFE_` class lifecycle methods like [`UNSAFE_componentWillMount`](/reference/react/Component#unsafe_componentwillmount). [See alternatives.](https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#migrating-from-legacy-lifecycles)
diff --git a/src/content/reference/react/Suspense.md b/src/content/reference/react/Suspense.md
index abb77a9df0c..ceeb34ce6b9 100644
--- a/src/content/reference/react/Suspense.md
+++ b/src/content/reference/react/Suspense.md
@@ -29,7 +29,7 @@ title:
#### Caveats {/*caveats*/}
-- React does not preserve any state for renders that got suspended before they were able to mount for the first time. When the component has loaded, React will retry rendering the suspended tree from scratch.
+- React does not preserve any state for renders that got suspended before they were able to mount for the first time. When the Component has loaded, React will retry rendering the suspended tree from scratch.
- If Suspense was displaying content for the tree, but then it suspended again, the `fallback` will be shown again unless the update causing it was caused by [`startTransition`](/reference/react/startTransition) or [`useDeferredValue`](/reference/react/useDeferredValue).
- If React needs to hide the already visible content because it suspended again, it will clean up [layout Effects](/reference/react/useLayoutEffect) in the content tree. When the content is ready to be shown again, React will fire the layout Effects again. This ensures that Effects measuring the DOM layout don't try to do this while the content is hidden.
- React includes under-the-hood optimizations like *Streaming Server Rendering* and *Selective Hydration* that are integrated with Suspense. Read [an architectural overview](https://github.com/reactwg/react-18/discussions/37) and watch [a technical talk](https://www.youtube.com/watch?v=pj5N-Khihgc) to learn more.
@@ -50,7 +50,7 @@ You can wrap any part of your application with a Suspense boundary:
React will display your loading fallback until all the code and data needed by the children has been loaded.
-In the example below, the `Albums` component *suspends* while fetching the list of albums. Until it's ready to render, React switches the closest Suspense boundary above to show the fallback--your `Loading` component. Then, when the data loads, React hides the `Loading` fallback and renders the `Albums` component with data.
+In the example below, the `Albums` Component *suspends* while fetching the list of albums. Until it's ready to render, React switches the closest Suspense boundary above to show the fallback--your `Loading` component. Then, when the data loads, React hides the `Loading` fallback and renders the `Albums` Component with data.
@@ -117,7 +117,7 @@ function Loading() {
```js src/Albums.js hidden
import { fetchData } from './data.js';
-// Note: this component is written using an experimental API
+// Note: this Component is written using an experimental API
// that's not yet available in stable versions of React.
// For a realistic example you can follow today, try a framework
@@ -253,12 +253,12 @@ async function getAlbums() {
**Only Suspense-enabled data sources will activate the Suspense component.** They include:
- Data fetching with Suspense-enabled frameworks like [Relay](https://relay.dev/docs/guided-tour/rendering/loading-states/) and [Next.js](https://nextjs.org/docs/getting-started/react-essentials)
-- Lazy-loading component code with [`lazy`](/reference/react/lazy)
+- Lazy-loading Component code with [`lazy`](/reference/react/lazy)
- Reading the value of a Promise with [`use`](/reference/react/use)
Suspense **does not** detect when data is fetched inside an Effect or event handler.
-The exact way you would load data in the `Albums` component above depends on your framework. If you use a Suspense-enabled framework, you'll find the details in its data fetching documentation.
+The exact way you would load data in the `Albums` Component above depends on your framework. If you use a Suspense-enabled framework, you'll find the details in its data fetching documentation.
Suspense-enabled data fetching without the use of an opinionated framework is not yet supported. The requirements for implementing a Suspense-enabled data source are unstable and undocumented. An official API for integrating data sources with Suspense will be released in a future version of React.
@@ -268,7 +268,7 @@ Suspense-enabled data fetching without the use of an opinionated framework is no
### Revealing content together at once {/*revealing-content-together-at-once*/}
-By default, the whole tree inside Suspense is treated as a single unit. For example, even if *only one* of these components suspends waiting for some data, *all* of them together will be replaced by the loading indicator:
+By default, the whole tree inside Suspense is treated as a single unit. For example, even if *only one* of these Components suspends waiting for some data, *all* of them together will be replaced by the loading indicator:
```js {2-5}
}>
@@ -281,7 +281,7 @@ By default, the whole tree inside Suspense is treated as a single unit. For exam
Then, after all of them are ready to be displayed, they will all appear together at once.
-In the example below, both `Biography` and `Albums` fetch some data. However, because they are grouped under a single Suspense boundary, these components always "pop in" together at the same time.
+In the example below, both `Biography` and `Albums` fetch some data. However, because they are grouped under a single Suspense boundary, these Components always "pop in" together at the same time.
@@ -363,7 +363,7 @@ export default function Panel({ children }) {
```js src/Biography.js hidden
import { fetchData } from './data.js';
-// Note: this component is written using an experimental API
+// Note: this Component is written using an experimental API
// that's not yet available in stable versions of React.
// For a realistic example you can follow today, try a framework
@@ -407,7 +407,7 @@ function use(promise) {
```js src/Albums.js hidden
import { fetchData } from './data.js';
-// Note: this component is written using an experimental API
+// Note: this Component is written using an experimental API
// that's not yet available in stable versions of React.
// For a realistic example you can follow today, try a framework
@@ -586,7 +586,7 @@ function Details({ artistId }) {
### Revealing nested content as it loads {/*revealing-nested-content-as-it-loads*/}
-When a component suspends, the closest parent Suspense component shows the fallback. This lets you nest multiple Suspense components to create a loading sequence. Each Suspense boundary's fallback will be filled in as the next level of content becomes available. For example, you can give the album list its own fallback:
+When a Component suspends, the closest parent Suspense Component shows the fallback. This lets you nest multiple Suspense Components to create a loading sequence. Each Suspense boundary's fallback will be filled in as the next level of content becomes available. For example, you can give the album list its own fallback:
```js {3,7}
}>
@@ -700,7 +700,7 @@ export default function Panel({ children }) {
```js src/Biography.js hidden
import { fetchData } from './data.js';
-// Note: this component is written using an experimental API
+// Note: this Component is written using an experimental API
// that's not yet available in stable versions of React.
// For a realistic example you can follow today, try a framework
@@ -744,7 +744,7 @@ function use(promise) {
```js src/Albums.js hidden
import { fetchData } from './data.js';
-// Note: this component is written using an experimental API
+// Note: this Component is written using an experimental API
// that's not yet available in stable versions of React.
// For a realistic example you can follow today, try a framework
@@ -925,7 +925,7 @@ Don't put a Suspense boundary around every component. Suspense boundaries should
### Showing stale content while fresh content is loading {/*showing-stale-content-while-fresh-content-is-loading*/}
-In this example, the `SearchResults` component suspends while fetching the search results. Type `"a"`, wait for the results, and then edit it to `"ab"`. The results for `"a"` will get replaced by the loading fallback.
+In this example, the `SearchResults` Component suspends while fetching the search results. Type `"a"`, wait for the results, and then edit it to `"ab"`. The results for `"a"` will get replaced by the loading fallback.
@@ -967,7 +967,7 @@ export default function App() {
```js src/SearchResults.js hidden
import { fetchData } from './data.js';
-// Note: this component is written using an experimental API
+// Note: this Component is written using an experimental API
// that's not yet available in stable versions of React.
// For a realistic example you can follow today, try a framework
@@ -1196,7 +1196,7 @@ export default function App() {
```js src/SearchResults.js hidden
import { fetchData } from './data.js';
-// Note: this component is written using an experimental API
+// Note: this Component is written using an experimental API
// that's not yet available in stable versions of React.
// For a realistic example you can follow today, try a framework
@@ -1356,7 +1356,7 @@ Both deferred values and [Transitions](#preventing-already-revealed-content-from
### Preventing already revealed content from hiding {/*preventing-already-revealed-content-from-hiding*/}
-When a component suspends, the closest parent Suspense boundary switches to showing the fallback. This can lead to a jarring user experience if it was already displaying some content. Try pressing this button:
+When a Component suspends, the closest parent Suspense boundary switches to showing the fallback. This can lead to a jarring user experience if it was already displaying some content. Try pressing this button:
@@ -1482,7 +1482,7 @@ function AlbumsGlimmer() {
```js src/Albums.js hidden
import { fetchData } from './data.js';
-// Note: this component is written using an experimental API
+// Note: this Component is written using an experimental API
// that's not yet available in stable versions of React.
// For a realistic example you can follow today, try a framework
@@ -1530,7 +1530,7 @@ function use(promise) {
```js src/Biography.js hidden
import { fetchData } from './data.js';
-// Note: this component is written using an experimental API
+// Note: this Component is written using an experimental API
// that's not yet available in stable versions of React.
// For a realistic example you can follow today, try a framework
@@ -1725,7 +1725,7 @@ main {
-When you pressed the button, the `Router` component rendered `ArtistPage` instead of `IndexPage`. A component inside `ArtistPage` suspended, so the closest Suspense boundary started showing the fallback. The closest Suspense boundary was near the root, so the whole site layout got replaced by `BigSpinner`.
+When you pressed the button, the `Router` Component rendered `ArtistPage` instead of `IndexPage`. A Component inside `ArtistPage` suspended, so the closest Suspense boundary started showing the fallback. The closest Suspense boundary was near the root, so the whole site layout got replaced by `BigSpinner`.
To prevent this, you can mark the navigation state update as a *Transition* with [`startTransition`:](/reference/react/startTransition)
@@ -1869,7 +1869,7 @@ function AlbumsGlimmer() {
```js src/Albums.js hidden
import { fetchData } from './data.js';
-// Note: this component is written using an experimental API
+// Note: this Component is written using an experimental API
// that's not yet available in stable versions of React.
// For a realistic example you can follow today, try a framework
@@ -1917,7 +1917,7 @@ function use(promise) {
```js src/Biography.js hidden
import { fetchData } from './data.js';
-// Note: this component is written using an experimental API
+// Note: this Component is written using an experimental API
// that's not yet available in stable versions of React.
// For a realistic example you can follow today, try a framework
@@ -2255,7 +2255,7 @@ function AlbumsGlimmer() {
```js src/Albums.js hidden
import { fetchData } from './data.js';
-// Note: this component is written using an experimental API
+// Note: this Component is written using an experimental API
// that's not yet available in stable versions of React.
// For a realistic example you can follow today, try a framework
@@ -2303,7 +2303,7 @@ function use(promise) {
```js src/Biography.js hidden
import { fetchData } from './data.js';
-// Note: this component is written using an experimental API
+// Note: this Component is written using an experimental API
// that's not yet available in stable versions of React.
// For a realistic example you can follow today, try a framework
@@ -2516,11 +2516,11 @@ However, now imagine you're navigating between two different user profiles. In t
### Providing a fallback for server errors and client-only content {/*providing-a-fallback-for-server-errors-and-client-only-content*/}
-If you use one of the [streaming server rendering APIs](/reference/react-dom/server) (or a framework that relies on them), React will also use your `` boundaries to handle errors on the server. If a component throws an error on the server, React will not abort the server render. Instead, it will find the closest `` component above it and include its fallback (such as a spinner) into the generated server HTML. The user will see a spinner at first.
+If you use one of the [streaming server rendering APIs](/reference/react-dom/server) (or a framework that relies on them), React will also use your `` boundaries to handle errors on the server. If a Component throws an error on the server, React will not abort the server render. Instead, it will find the closest `` Component above it and include its fallback (such as a spinner) into the generated server HTML. The user will see a spinner at first.
-On the client, React will attempt to render the same component again. If it errors on the client too, React will throw the error and display the closest [error boundary.](/reference/react/Component#static-getderivedstatefromerror) However, if it does not error on the client, React will not display the error to the user since the content was eventually displayed successfully.
+On the client, React will attempt to render the same Component again. If it errors on the client too, React will throw the error and display the closest [error boundary.](/reference/react/Component#static-getderivedstatefromerror) However, if it does not error on the client, React will not display the error to the user since the content was eventually displayed successfully.
-You can use this to opt out some components from rendering on the server. To do this, throw an error in the server environment and then wrap them in a `` boundary to replace their HTML with fallbacks:
+You can use this to opt out some Components from rendering on the server. To do this, throw an error in the server environment and then wrap them in a `` boundary to replace their HTML with fallbacks:
```js
}>
@@ -2535,7 +2535,7 @@ function Chat() {
}
```
-The server HTML will include the loading indicator. It will be replaced by the `Chat` component on the client.
+The server HTML will include the loading indicator. It will be replaced by the `Chat` Component on the client.
---
@@ -2543,7 +2543,7 @@ The server HTML will include the loading indicator. It will be replaced by the `
### How do I prevent the UI from being replaced by a fallback during an update? {/*preventing-unwanted-fallbacks*/}
-Replacing visible UI with a fallback creates a jarring user experience. This can happen when an update causes a component to suspend, and the nearest Suspense boundary is already showing content to the user.
+Replacing visible UI with a fallback creates a jarring user experience. This can happen when an update causes a Component to suspend, and the nearest Suspense boundary is already showing content to the user.
To prevent this from happening, [mark the update as non-urgent using `startTransition`](#preventing-already-revealed-content-from-hiding). During a Transition, React will wait until enough data has loaded to prevent an unwanted fallback from appearing:
diff --git a/src/content/reference/react/apis.md b/src/content/reference/react/apis.md
index 9c143787030..936362c4412 100644
--- a/src/content/reference/react/apis.md
+++ b/src/content/reference/react/apis.md
@@ -11,7 +11,7 @@ In addition to [Hooks](/reference/react) and [Components](/reference/react/compo
---
* [`createContext`](/reference/react/createContext) lets you define and provide context to the child components. Used with [`useContext`.](/reference/react/useContext)
-* [`forwardRef`](/reference/react/forwardRef) lets your component expose a DOM node as a ref to the parent. Used with [`useRef`.](/reference/react/useRef)
+* [`forwardRef`](/reference/react/forwardRef) lets your Component expose a DOM node as a ref to the parent. Used with [`useRef`.](/reference/react/useRef)
* [`lazy`](/reference/react/lazy) lets you defer loading a component's code until it's rendered for the first time.
-* [`memo`](/reference/react/memo) lets your component skip re-renders with same props. Used with [`useMemo`](/reference/react/useMemo) and [`useCallback`.](/reference/react/useCallback)
+* [`memo`](/reference/react/memo) lets your Component skip re-renders with same props. Used with [`useMemo`](/reference/react/useMemo) and [`useCallback`.](/reference/react/useCallback)
* [`startTransition`](/reference/react/startTransition) lets you mark a state update as non-urgent. Similar to [`useTransition`.](/reference/react/useTransition)
diff --git a/src/content/reference/react/cache.md b/src/content/reference/react/cache.md
index 735560636a3..c003c07f9fd 100644
--- a/src/content/reference/react/cache.md
+++ b/src/content/reference/react/cache.md
@@ -27,7 +27,7 @@ const cachedFn = cache(fn);
### `cache(fn)` {/*cache*/}
-Call `cache` outside of any components to create a version of the function with caching.
+Call `cache` outside of any Components to create a version of the function with caching.
```js {4,7}
import {cache} from 'react';
@@ -98,7 +98,7 @@ function TeamReport({users}) {
}
```
-If the same `user` object is rendered in both `Profile` and `TeamReport`, the two components can share work and only call `calculateUserMetrics` once for that `user`.
+If the same `user` object is rendered in both `Profile` and `TeamReport`, the two Components can share work and only call `calculateUserMetrics` once for that `user`.
Assume `Profile` is rendered first. It will call `getUserMetrics`, and check if there is a cached result. Since it is the first time `getUserMetrics` is called with that `user`, there will be a cache miss. `getUserMetrics` will then call `calculateUserMetrics` with that `user` and write the result to cache.
@@ -108,7 +108,7 @@ When `TeamReport` renders its list of `users` and reaches the same `user` object
##### Calling different memoized functions will read from different caches. {/*pitfall-different-memoized-functions*/}
-To access the same cache, components must call the same memoized function.
+To access the same cache, Components must call the same memoized function.
```js [[1, 7, "getWeekReport"], [1, 7, "cache(calculateWeekReport)"], [1, 8, "getWeekReport"]]
// Temperature.js
@@ -116,7 +116,7 @@ import {cache} from 'react';
import {calculateWeekReport} from './report';
export function Temperature({cityData}) {
- // 🚩 Wrong: Calling `cache` in component creates new `getWeekReport` for each render
+ // 🚩 Wrong: Calling `cache` in Component creates new `getWeekReport` for each render
const getWeekReport = cache(calculateWeekReport);
const report = getWeekReport(cityData);
// ...
@@ -137,11 +137,11 @@ export function Precipitation({cityData}) {
}
```
-In the above example, `Precipitation` and `Temperature` each call `cache` to create a new memoized function with their own cache look-up. If both components render for the same `cityData`, they will do duplicate work to call `calculateWeekReport`.
+In the above example, `Precipitation` and `Temperature` each call `cache` to create a new memoized function with their own cache look-up. If both Components render for the same `cityData`, they will do duplicate work to call `calculateWeekReport`.
-In addition, `Temperature` creates a new memoized function each time the component is rendered which doesn't allow for any cache sharing.
+In addition, `Temperature` creates a new memoized function each time the Component is rendered which doesn't allow for any cache sharing.
-To maximize cache hits and reduce work, the two components should call the same memoized function to access the same cache. Instead, define the memoized function in a dedicated module that can be [`import`-ed](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) across components.
+To maximize cache hits and reduce work, the two Components should call the same memoized function to access the same cache. Instead, define the memoized function in a dedicated module that can be [`import`-ed](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) across components.
```js [[3, 5, "export default cache(calculateWeekReport)"]]
// getWeekReport.js
@@ -170,12 +170,12 @@ export default function Precipitation({cityData}) {
// ...
}
```
-Here, both components call the same memoized function exported from `./getWeekReport.js` to read and write to the same cache.
+Here, both Components call the same memoized function exported from `./getWeekReport.js` to read and write to the same cache.
### Share a snapshot of data {/*take-and-share-snapshot-of-data*/}
-To share a snapshot of data between components, call `cache` with a data-fetching function like `fetch`. When multiple components make the same data fetch, only one request is made and the data returned is cached and shared across components. All components refer to the same snapshot of data across the server render.
+To share a snapshot of data between components, call `cache` with a data-fetching function like `fetch`. When multiple Components make the same data fetch, only one request is made and the data returned is cached and shared across components. All Components refer to the same snapshot of data across the server render.
```js [[1, 4, "city"], [1, 5, "fetchTemperature(city)"], [2, 4, "getTemperature"], [2, 9, "getTemperature"], [1, 9, "city"], [2, 14, "getTemperature"], [1, 14, "city"]]
import {cache} from 'react';
@@ -215,7 +215,7 @@ async function AnimatedWeatherCard({city}) {
}
```
[//]: # 'TODO: add link and mention to use documentation when merged'
-[//]: # 'To render components that use asynchronous data in Client Components, see `use` documentation.'
+[//]: # 'To render Components that use asynchronous data in Client Components, see `use` documentation.'
@@ -250,7 +250,7 @@ function Page({id}) {
}
```
-When rendering `Page`, the component calls `getUser` but note that it doesn't use the returned data. This early `getUser` call kicks off the asynchronous database query that occurs while `Page` is doing other computational work and rendering children.
+When rendering `Page`, the Component calls `getUser` but note that it doesn't use the returned data. This early `getUser` call kicks off the asynchronous database query that occurs while `Page` is doing other computational work and rendering children.
When rendering `Profile`, we call `getUser` again. If the initial `getUser` call has already returned and cached the user data, when `Profile` asks and waits for this data, it can simply read from the cache without requiring another remote procedure call. If the initial data request hasn't been completed, preloading data in this pattern reduces delay in data-fetching.
@@ -288,7 +288,7 @@ If the promise is already settled, either to an error or the _fulfilled_ result,
-##### Calling a memoized function outside of a component will not use the cache. {/*pitfall-memoized-call-outside-component*/}
+##### Calling a memoized function outside of a Component will not use the cache. {/*pitfall-memoized-call-outside-component*/}
```jsx [[1, 3, "getUser"]]
import {cache} from 'react';
@@ -297,7 +297,7 @@ const getUser = cache(async (userId) => {
return await db.user.query(userId);
});
-// 🚩 Wrong: Calling memoized function outside of component will not memoize.
+// 🚩 Wrong: Calling memoized function outside of Component will not memoize.
getUser('demo-id');
async function DemoProfile() {
@@ -341,9 +341,9 @@ function App() {
);
}
```
-In this example, `App` renders two `WeatherReport`s with the same record. Even though both components do the same work, they cannot share work. `useMemo`'s cache is only local to the component.
+In this example, `App` renders two `WeatherReport`s with the same record. Even though both Components do the same work, they cannot share work. `useMemo`'s cache is only local to the component.
-However, `useMemo` does ensure that if `App` re-renders and the `record` object doesn't change, each component instance would skip work and use the memoized value of `avgTemp`. `useMemo` will only cache the last computation of `avgTemp` with the given dependencies.
+However, `useMemo` does ensure that if `App` re-renders and the `record` object doesn't change, each Component instance would skip work and use the memoized value of `avgTemp`. `useMemo` will only cache the last computation of `avgTemp` with the given dependencies.
#### `cache` {/*deep-dive-cache*/}
@@ -373,7 +373,7 @@ At this time, `cache` should only be used in Server Components and the cache wil
#### `memo` {/*deep-dive-memo*/}
-You should use [`memo`](reference/react/memo) to prevent a component re-rendering if its props are unchanged.
+You should use [`memo`](reference/react/memo) to prevent a Component re-rendering if its props are unchanged.
```js
'use client';
@@ -396,9 +396,9 @@ function App() {
}
```
-In this example, both `MemoWeatherReport` components will call `calculateAvg` when first rendered. However, if `App` re-renders, with no changes to `record`, none of the props have changed and `MemoWeatherReport` will not re-render.
+In this example, both `MemoWeatherReport` Components will call `calculateAvg` when first rendered. However, if `App` re-renders, with no changes to `record`, none of the props have changed and `MemoWeatherReport` will not re-render.
-Compared to `useMemo`, `memo` memoizes the component render based on props vs. specific computations. Similar to `useMemo`, the memoized component only caches the last render with the last prop values. Once the props change, the cache invalidates and the component re-renders.
+Compared to `useMemo`, `memo` memoizes the Component render based on props vs. specific computations. Similar to `useMemo`, the memoized Component only caches the last render with the last prop values. Once the props change, the cache invalidates and the Component re-renders.
@@ -410,7 +410,7 @@ Compared to `useMemo`, `memo` memoizes the component render based on props vs. s
See prior mentioned pitfalls
* [Calling different memoized functions will read from different caches.](#pitfall-different-memoized-functions)
-* [Calling a memoized function outside of a component will not use the cache.](#pitfall-memoized-call-outside-component)
+* [Calling a memoized function outside of a Component will not use the cache.](#pitfall-memoized-call-outside-component)
If none of the above apply, it may be a problem with how React checks if something exists in cache.
@@ -441,7 +441,7 @@ function App() {
}
```
-In this case the two `MapMarker`s look like they're doing the same work and calling `calculateNorm` with the same value of `{x: 10, y: 10, z:10}`. Even though the objects contain the same values, they are not the same object reference as each component creates its own `props` object.
+In this case the two `MapMarker`s look like they're doing the same work and calling `calculateNorm` with the same value of `{x: 10, y: 10, z:10}`. Even though the objects contain the same values, they are not the same object reference as each Component creates its own `props` object.
React will call [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is) on the input to verify if there is a cache hit.
@@ -470,7 +470,7 @@ function App() {
One way to address this could be to pass the vector dimensions to `calculateNorm`. This works because the dimensions themselves are primitives.
-Another solution may be to pass the vector object itself as a prop to the component. We'll need to pass the same object to both component instances.
+Another solution may be to pass the vector object itself as a prop to the component. We'll need to pass the same object to both Component instances.
```js {3,9,14}
import {cache} from 'react';
diff --git a/src/content/reference/react/cloneElement.md b/src/content/reference/react/cloneElement.md
index 6bcea51b057..0e4fc36d2a0 100644
--- a/src/content/reference/react/cloneElement.md
+++ b/src/content/reference/react/cloneElement.md
@@ -62,7 +62,7 @@ console.log(clonedElement); // Goodbye
* `ref`: The original `element.ref`, unless it was overridden by `props.ref`.
* `key`: The original `element.key`, unless it was overridden by `props.key`.
-Usually, you'll return the element from your component or make it a child of another element. Although you may read the element's properties, it's best to treat every element as opaque after it's created, and only render it.
+Usually, you'll return the element from your Component or make it a child of another element. Although you may read the element's properties, it's best to treat every element as opaque after it's created, and only render it.
#### Caveats {/*caveats*/}
@@ -94,7 +94,7 @@ Here, the resulting cloned element will be `` child that it has received, and adds an extra `isHighlighted: true` or `isHighlighted: false` prop:
+Imagine a `List` Component that renders its [`children`](/learn/passing-props-to-a-component#passing-jsx-as-children) as a list of selectable rows with a "Next" button that changes which row is selected. The `List` Component needs to render the selected `Row` differently, so it clones every `` child that it has received, and adds an extra `isHighlighted: true` or `isHighlighted: false` prop:
```js {6-8}
export default function List({ children }) {
@@ -404,7 +404,7 @@ For example, you can call [`createContext`](/reference/react/createContext) to d
export const HighlightContext = createContext(false);
```
-Your `List` component can wrap every item it renders into a `HighlightContext` provider:
+Your `List` Component can wrap every item it renders into a `HighlightContext` provider:
```js {8,10}
export default function List({ items, renderItem }) {
@@ -429,7 +429,7 @@ export default function Row({ title }) {
// ...
```
-This allows the calling component to not know or worry about passing `isHighlighted` to ``:
+This allows the calling Component to not know or worry about passing `isHighlighted` to ``:
```js {4}
-React exposes a few built-in components that you can use in your JSX.
+React exposes a few built-in Components that you can use in your JSX.
---
-## Built-in components {/*built-in-components*/}
+## Built-in Components {/*built-in-components*/}
* [``](/reference/react/Fragment), alternatively written as `<>...>`, lets you group multiple JSX nodes together.
* [``](/reference/react/Profiler) lets you measure rendering performance of a React tree programmatically.
-* [``](/reference/react/Suspense) lets you display a fallback while the child components are loading.
+* [``](/reference/react/Suspense) lets you display a fallback while the child Components are loading.
* [``](/reference/react/StrictMode) enables extra development-only checks that help you find bugs early.
---
-## Your own components {/*your-own-components*/}
+## Your own Components {/*your-own-components*/}
You can also [define your own components](/learn/your-first-component) as JavaScript functions.
diff --git a/src/content/reference/react/createContext.md b/src/content/reference/react/createContext.md
index a653633c1d7..1af8c67dde8 100644
--- a/src/content/reference/react/createContext.md
+++ b/src/content/reference/react/createContext.md
@@ -4,7 +4,7 @@ title: createContext
-`createContext` lets you create a [context](/learn/passing-data-deeply-with-context) that components can provide or read.
+`createContext` lets you create a [context](/learn/passing-data-deeply-with-context) that Components can provide or read.
```js
const SomeContext = createContext(defaultValue)
@@ -20,7 +20,7 @@ const SomeContext = createContext(defaultValue)
### `createContext(defaultValue)` {/*createcontext*/}
-Call `createContext` outside of any components to create a context.
+Call `createContext` outside of any Components to create a context.
```js
import { createContext } from 'react';
@@ -32,13 +32,13 @@ const ThemeContext = createContext('light');
#### Parameters {/*parameters*/}
-* `defaultValue`: The value that you want the context to have when there is no matching context provider in the tree above the component that reads context. If you don't have any meaningful default value, specify `null`. The default value is meant as a "last resort" fallback. It is static and never changes over time.
+* `defaultValue`: The value that you want the context to have when there is no matching context provider in the tree above the Component that reads context. If you don't have any meaningful default value, specify `null`. The default value is meant as a "last resort" fallback. It is static and never changes over time.
#### Returns {/*returns*/}
`createContext` returns a context object.
-**The context object itself does not hold any information.** It represents _which_ context other components read or provide. Typically, you will use [`SomeContext.Provider`](#provider) in components above to specify the context value, and call [`useContext(SomeContext)`](/reference/react/useContext) in components below to read it. The context object has a few properties:
+**The context object itself does not hold any information.** It represents _which_ context other Components read or provide. Typically, you will use [`SomeContext.Provider`](#provider) in Components above to specify the context value, and call [`useContext(SomeContext)`](/reference/react/useContext) in Components below to read it. The context object has a few properties:
* `SomeContext.Provider` lets you provide the context value to components.
* `SomeContext.Consumer` is an alternative and rarely used way to read the context value.
@@ -47,7 +47,7 @@ const ThemeContext = createContext('light');
### `SomeContext.Provider` {/*provider*/}
-Wrap your components into a context provider to specify the value of this context for all components inside:
+Wrap your Components into a context provider to specify the value of this context for all Components inside:
```js
function App() {
@@ -63,7 +63,7 @@ function App() {
#### Props {/*provider-props*/}
-* `value`: The value that you want to pass to all the components reading this context inside this provider, no matter how deep. The context value can be of any type. A component calling [`useContext(SomeContext)`](/reference/react/useContext) inside of the provider receives the `value` of the innermost corresponding context provider above it.
+* `value`: The value that you want to pass to all the Components reading this context inside this provider, no matter how deep. The context value can be of any type. A Component calling [`useContext(SomeContext)`](/reference/react/useContext) inside of the provider receives the `value` of the innermost corresponding context provider above it.
---
@@ -96,7 +96,7 @@ function Button() {
#### Props {/*consumer-props*/}
-* `children`: A function. React will call the function you pass with the current context value determined by the same algorithm as [`useContext()`](/reference/react/useContext) does, and render the result you return from this function. React will also re-run this function and update the UI whenever the context from the parent components changes.
+* `children`: A function. React will call the function you pass with the current context value determined by the same algorithm as [`useContext()`](/reference/react/useContext) does, and render the result you return from this function. React will also re-run this function and update the UI whenever the context from the parent Components changes.
---
@@ -104,9 +104,9 @@ function Button() {
### Creating context {/*creating-context*/}
-Context lets components [pass information deep down](/learn/passing-data-deeply-with-context) without explicitly passing props.
+Context lets Components [pass information deep down](/learn/passing-data-deeply-with-context) without explicitly passing props.
-Call `createContext` outside any components to create one or more contexts.
+Call `createContext` outside any Components to create one or more contexts.
```js [[1, 3, "ThemeContext"], [1, 4, "AuthContext"], [3, 3, "'light'"], [3, 4, "null"]]
import { createContext } from 'react';
@@ -150,7 +150,7 @@ function App() {
}
```
-Now the `Page` component and any components inside it, no matter how deep, will "see" the passed context values. If the passed context values change, React will re-render the components reading the context as well.
+Now the `Page` Component and any Components inside it, no matter how deep, will "see" the passed context values. If the passed context values change, React will re-render the Components reading the context as well.
[Read more about reading and providing context and see examples.](/reference/react/useContext)
@@ -158,7 +158,7 @@ Now the `Page` component and any components inside it, no matter how deep, will
### Importing and exporting context from a file {/*importing-and-exporting-context-from-a-file*/}
-Often, components in different files will need access to the same context. This is why it's common to declare contexts in a separate file. Then you can use the [`export` statement](https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/export) to make context available for other files:
+Often, Components in different files will need access to the same context. This is why it's common to declare contexts in a separate file. Then you can use the [`export` statement](https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/export) to make context available for other files:
```js {4-5}
// Contexts.js
@@ -213,5 +213,5 @@ const ThemeContext = createContext('light');
This value never changes. React only uses this value as a fallback if it can't find a matching provider above.
-To make context change over time, [add state and wrap components in a context provider.](/reference/react/useContext#updating-data-passed-via-context)
+To make context change over time, [add state and wrap Components in a context provider.](/reference/react/useContext#updating-data-passed-via-context)
diff --git a/src/content/reference/react/createElement.md b/src/content/reference/react/createElement.md
index a5f684c66f9..88772444d9d 100644
--- a/src/content/reference/react/createElement.md
+++ b/src/content/reference/react/createElement.md
@@ -38,7 +38,7 @@ function Greeting({ name }) {
#### Parameters {/*parameters*/}
-* `type`: The `type` argument must be a valid React component type. For example, it could be a tag name string (such as `'div'` or `'span'`), or a React component (a function, a class, or a special component like [`Fragment`](/reference/react/Fragment)).
+* `type`: The `type` argument must be a valid React Component type. For example, it could be a tag name string (such as `'div'` or `'span'`), or a React Component (a function, a class, or a special Component like [`Fragment`](/reference/react/Fragment)).
* `props`: The `props` argument must either be an object or `null`. If you pass `null`, it will be treated the same as an empty object. React will create an element with props matching the `props` you have passed. Note that `ref` and `key` from your `props` object are special and will *not* be available as `element.props.ref` and `element.props.key` on the returned `element`. They will be available as `element.ref` and `element.key`.
@@ -49,11 +49,11 @@ function Greeting({ name }) {
`createElement` returns a React element object with a few properties:
* `type`: The `type` you have passed.
-* `props`: The `props` you have passed except for `ref` and `key`. If the `type` is a component with legacy `type.defaultProps`, then any missing or undefined `props` will get the values from `type.defaultProps`.
+* `props`: The `props` you have passed except for `ref` and `key`. If the `type` is a Component with legacy `type.defaultProps`, then any missing or undefined `props` will get the values from `type.defaultProps`.
* `ref`: The `ref` you have passed. If missing, `null`.
* `key`: The `key` you have passed, coerced to a string. If missing, `null`.
-Usually, you'll return the element from your component or make it a child of another element. Although you may read the element's properties, it's best to treat every element as opaque after it's created, and only render it.
+Usually, you'll return the element from your Component or make it a child of another element. Although you may read the element's properties, it's best to treat every element as opaque after it's created, and only render it.
#### Caveats {/*caveats*/}
@@ -196,7 +196,7 @@ An element is a lightweight description of a piece of the user interface. For ex
}
```
-**Note that creating this object does not render the `Greeting` component or create any DOM elements.**
+**Note that creating this object does not render the `Greeting` Component or create any DOM elements.**
A React element is more like a description--an instruction for React to later render the `Greeting` component. By returning this object from your `App` component, you tell React what to do next.
diff --git a/src/content/reference/react/createFactory.md b/src/content/reference/react/createFactory.md
index 7df7fcd8775..226b932b572 100644
--- a/src/content/reference/react/createFactory.md
+++ b/src/content/reference/react/createFactory.md
@@ -50,7 +50,7 @@ export default function App() {
#### Parameters {/*parameters*/}
-* `type`: The `type` argument must be a valid React component type. For example, it could be a tag name string (such as `'div'` or `'span'`), or a React component (a function, a class, or a special component like [`Fragment`](/reference/react/Fragment)).
+* `type`: The `type` argument must be a valid React Component type. For example, it could be a tag name string (such as `'div'` or `'span'`), or a React Component (a function, a class, or a special Component like [`Fragment`](/reference/react/Fragment)).
#### Returns {/*returns*/}
diff --git a/src/content/reference/react/createRef.md b/src/content/reference/react/createRef.md
index 2a3ba6aa3df..a2a23a892b9 100644
--- a/src/content/reference/react/createRef.md
+++ b/src/content/reference/react/createRef.md
@@ -4,7 +4,7 @@ title: createRef
-`createRef` is mostly used for [class components.](/reference/react/Component) Function components typically rely on [`useRef`](/reference/react/useRef) instead.
+`createRef` is mostly used for [class components.](/reference/react/Component) Function Components typically rely on [`useRef`](/reference/react/useRef) instead.
@@ -62,7 +62,7 @@ class MyComponent extends Component {
## Usage {/*usage*/}
-### Declaring a ref in a class component {/*declaring-a-ref-in-a-class-component*/}
+### Declaring a ref in a class Component {/*declaring-a-ref-in-a-class-component*/}
To declare a ref inside a [class component,](/reference/react/Component) call `createRef` and assign its result to a class field:
@@ -107,7 +107,7 @@ export default class Form extends Component {
-`createRef` is mostly used for [class components.](/reference/react/Component) Function components typically rely on [`useRef`](/reference/react/useRef) instead.
+`createRef` is mostly used for [class components.](/reference/react/Component) Function Components typically rely on [`useRef`](/reference/react/useRef) instead.
@@ -117,7 +117,7 @@ export default class Form extends Component {
### Migrating from a class with `createRef` to a function with `useRef` {/*migrating-from-a-class-with-createref-to-a-function-with-useref*/}
-We recommend using function components instead of [class components](/reference/react/Component) in new code. If you have some existing class components using `createRef`, here is how you can convert them. This is the original code:
+We recommend using function Components instead of [class components](/reference/react/Component) in new code. If you have some existing class Components using `createRef`, here is how you can convert them. This is the original code:
@@ -146,7 +146,7 @@ export default class Form extends Component {
-When you [convert this component from a class to a function,](/reference/react/Component#alternatives) replace calls to `createRef` with calls to [`useRef`:](/reference/react/useRef)
+When you [convert this Component from a class to a function,](/reference/react/Component#alternatives) replace calls to `createRef` with calls to [`useRef`:](/reference/react/useRef)
diff --git a/src/content/reference/react/forwardRef.md b/src/content/reference/react/forwardRef.md
index 04d69287ce2..1b4a1ed9f77 100644
--- a/src/content/reference/react/forwardRef.md
+++ b/src/content/reference/react/forwardRef.md
@@ -4,7 +4,7 @@ title: forwardRef
-`forwardRef` lets your component expose a DOM node to parent component with a [ref.](/learn/manipulating-the-dom-with-refs)
+`forwardRef` lets your Component expose a DOM node to parent Component with a [ref.](/learn/manipulating-the-dom-with-refs)
```js
const SomeComponent = forwardRef(render)
@@ -20,7 +20,7 @@ const SomeComponent = forwardRef(render)
### `forwardRef(render)` {/*forwardref*/}
-Call `forwardRef()` to let your component receive a ref and forward it to a child component:
+Call `forwardRef()` to let your Component receive a ref and forward it to a child component:
```js
import { forwardRef } from 'react';
@@ -34,11 +34,11 @@ const MyInput = forwardRef(function MyInput(props, ref) {
#### Parameters {/*parameters*/}
-* `render`: The render function for your component. React calls this function with the props and `ref` that your component received from its parent. The JSX you return will be the output of your component.
+* `render`: The render function for your component. React calls this function with the props and `ref` that your Component received from its parent. The JSX you return will be the output of your component.
#### Returns {/*returns*/}
-`forwardRef` returns a React component that you can render in JSX. Unlike React components defined as plain functions, a component returned by `forwardRef` is also able to receive a `ref` prop.
+`forwardRef` returns a React Component that you can render in JSX. Unlike React Components defined as plain functions, a Component returned by `forwardRef` is also able to receive a `ref` prop.
#### Caveats {/*caveats*/}
@@ -66,19 +66,19 @@ const MyInput = forwardRef(function MyInput(props, ref) {
* `props`: The props passed by the parent component.
-* `ref`: The `ref` attribute passed by the parent component. The `ref` can be an object or a function. If the parent component has not passed a ref, it will be `null`. You should either pass the `ref` you receive to another component, or pass it to [`useImperativeHandle`.](/reference/react/useImperativeHandle)
+* `ref`: The `ref` attribute passed by the parent component. The `ref` can be an object or a function. If the parent Component has not passed a ref, it will be `null`. You should either pass the `ref` you receive to another component, or pass it to [`useImperativeHandle`.](/reference/react/useImperativeHandle)
#### Returns {/*render-returns*/}
-`forwardRef` returns a React component that you can render in JSX. Unlike React components defined as plain functions, the component returned by `forwardRef` is able to take a `ref` prop.
+`forwardRef` returns a React Component that you can render in JSX. Unlike React Components defined as plain functions, the Component returned by `forwardRef` is able to take a `ref` prop.
---
## Usage {/*usage*/}
-### Exposing a DOM node to the parent component {/*exposing-a-dom-node-to-the-parent-component*/}
+### Exposing a DOM node to the parent Component {/*exposing-a-dom-node-to-the-parent-component*/}
-By default, each component's DOM nodes are private. However, sometimes it's useful to expose a DOM node to the parent--for example, to allow focusing it. To opt in, wrap your component definition into `forwardRef()`:
+By default, each component's DOM nodes are private. However, sometimes it's useful to expose a DOM node to the parent--for example, to allow focusing it. To opt in, wrap your Component definition into `forwardRef()`:
```js {3,11}
import { forwardRef } from 'react';
@@ -110,7 +110,7 @@ const MyInput = forwardRef(function MyInput(props, ref) {
});
```
-This lets the parent `Form` component access the `` DOM node exposed by `MyInput`:
+This lets the parent `Form` Component access the `` DOM node exposed by `MyInput`:
```js [[1, 2, "ref"], [1, 10, "ref", 41], [2, 5, "ref.current"]]
function Form() {
@@ -131,15 +131,15 @@ function Form() {
}
```
-This `Form` component [passes a ref](/reference/react/useRef#manipulating-the-dom-with-a-ref) to `MyInput`. The `MyInput` component *forwards* that ref to the `` browser tag. As a result, the `Form` component can access that `` DOM node and call [`focus()`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on it.
+This `Form` Component [passes a ref](/reference/react/useRef#manipulating-the-dom-with-a-ref) to `MyInput`. The `MyInput` Component *forwards* that ref to the `` browser tag. As a result, the `Form` Component can access that `` DOM node and call [`focus()`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on it.
-Keep in mind that exposing a ref to the DOM node inside your component makes it harder to change your component's internals later. You will typically expose DOM nodes from reusable low-level components like buttons or text inputs, but you won't do it for application-level components like an avatar or a comment.
+Keep in mind that exposing a ref to the DOM node inside your Component makes it harder to change your component's internals later. You will typically expose DOM nodes from reusable low-level Components like buttons or text inputs, but you won't do it for application-level Components like an avatar or a comment.
#### Focusing a text input {/*focusing-a-text-input*/}
-Clicking the button will focus the input. The `Form` component defines a ref and passes it to the `MyInput` component. The `MyInput` component forwards that ref to the browser ``. This lets the `Form` component focus the ``.
+Clicking the button will focus the input. The `Form` Component defines a ref and passes it to the `MyInput` component. The `MyInput` Component forwards that ref to the browser ``. This lets the `Form` Component focus the ``.
@@ -193,7 +193,7 @@ input {
#### Playing and pausing a video {/*playing-and-pausing-a-video*/}
-Clicking the button will call [`play()`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/play) and [`pause()`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/pause) on a `