From d8dda1cfbfd79a161715d5e7210ca13333532a34 Mon Sep 17 00:00:00 2001 From: Ryan Mario Date: Sat, 2 May 2026 19:17:21 +0530 Subject: [PATCH] fix: standardize capitalization of "State" and "Component" throughout managing-state.md --- src/content/learn/managing-state.md | 70 ++++++++++++++--------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/content/learn/managing-state.md b/src/content/learn/managing-state.md index ef7b76e04c2..aa5816931b7 100644 --- a/src/content/learn/managing-state.md +++ b/src/content/learn/managing-state.md @@ -4,27 +4,27 @@ title: Managing State -As your application grows, it helps to be more intentional about how your state is organized and how the data flows between your components. Redundant or duplicate state is a common source of bugs. In this chapter, you'll learn how to structure your state well, how to keep your state update logic maintainable, and how to share state between distant components. +As your application grows, it helps to be more intentional about how your State is organized and how the data flows between your Components. Redundant or duplicate State is a common source of bugs. In this chapter, you'll learn how to structure your State well, how to keep your State update logic maintainable, and how to share State between distant Components. -* [How to think about UI changes as state changes](/learn/reacting-to-input-with-state) -* [How to structure state well](/learn/choosing-the-state-structure) -* [How to "lift state up" to share it between components](/learn/sharing-state-between-components) -* [How to control whether the state gets preserved or reset](/learn/preserving-and-resetting-state) -* [How to consolidate complex state logic in a function](/learn/extracting-state-logic-into-a-reducer) +* [How to think about UI changes as State changes](/learn/reacting-to-input-with-state) +* [How to structure State well](/learn/choosing-the-state-structure) +* [How to "lift State up" to share it between Components](/learn/sharing-state-between-components) +* [How to control whether the State gets preserved or reset](/learn/preserving-and-resetting-state) +* [How to consolidate complex State logic in a function](/learn/extracting-state-logic-into-a-reducer) * [How to pass information without "prop drilling"](/learn/passing-data-deeply-with-context) -* [How to scale state management as your app grows](/learn/scaling-up-with-reducer-and-context) +* [How to scale State management as your app grows](/learn/scaling-up-with-reducer-and-context) -## Reacting to input with state {/*reacting-to-input-with-state*/} +## Reacting to Input with State {/*reacting-to-input-with-state*/} -With React, you won't modify the UI from code directly. For example, you won't write commands like "disable the button", "enable the button", "show the success message", etc. Instead, you will describe the UI you want to see for the different visual states of your component ("initial state", "typing state", "success state"), and then trigger the state changes in response to user input. This is similar to how designers think about UI. +With React, you won't modify the UI from code directly. For example, you won't write commands like "disable the button", "enable the button", "show the success message", etc. Instead, you will describe the UI you want to see for the different visual states of your Component ("initial state", "typing state", "success state"), and then trigger the State changes in response to user input. This is similar to how designers think about UI. -Here is a quiz form built using React. Note how it uses the `status` state variable to determine whether to enable or disable the submit button, and whether to show the success message instead. +Here is a quiz form built using React. Note how it uses the `status` State variable to determine whether to enable or disable the submit button, and whether to show the success message instead. @@ -108,15 +108,15 @@ function submitForm(answer) { -Read **[Reacting to Input with State](/learn/reacting-to-input-with-state)** to learn how to approach interactions with a state-driven mindset. +Read **[Reacting to Input with State](/learn/reacting-to-input-with-state)** to learn how to approach interactions with a State-driven mindset. -## Choosing the state structure {/*choosing-the-state-structure*/} +## Choosing the State Structure {/*choosing-the-state-structure*/} -Structuring state well can make a difference between a component that is pleasant to modify and debug, and one that is a constant source of bugs. The most important principle is that state shouldn't contain redundant or duplicated information. If there's unnecessary state, it's easy to forget to update it, and introduce bugs! +Structuring State well can make a difference between a Component that is pleasant to modify and debug, and one that is a constant source of bugs. The most important principle is that State shouldn't contain redundant or duplicated information. If there's unnecessary State, it's easy to forget to update it, and introduce bugs! -For example, this form has a **redundant** `fullName` state variable: +For example, this form has a **redundant** `fullName` State variable: @@ -169,7 +169,7 @@ label { display: block; margin-bottom: 5px; } -You can remove it and simplify the code by calculating `fullName` while the component is rendering: +You can remove it and simplify the code by calculating `fullName` while the Component is rendering: @@ -225,15 +225,15 @@ This might seem like a small change, but many bugs in React apps are fixed this -Read **[Choosing the State Structure](/learn/choosing-the-state-structure)** to learn how to design the state shape to avoid bugs. +Read **[Choosing the State Structure](/learn/choosing-the-state-structure)** to learn how to design the State shape to avoid bugs. -## Sharing state between components {/*sharing-state-between-components*/} +## Sharing State Between Components {/*sharing-state-between-components*/} -Sometimes, you want the state of two components to always change together. To do it, remove state from both of them, move it to their closest common parent, and then pass it down to them via props. This is known as "lifting state up", and it's one of the most common things you will do writing React code. +Sometimes, you want the State of two Components to always change together. To do it, remove State from both of them, move it to their closest common parent, and then pass it down to them via props. This is known as "lifting State up", and it's one of the most common things you will do writing React code. -In this example, only one panel should be active at a time. To achieve this, instead of keeping the active state inside each individual panel, the parent component holds the state and specifies the props for its children. +In this example, only one panel should be active at a time. To achieve this, instead of keeping the active State inside each individual panel, the parent Component holds the State and specifies the props for its children. @@ -296,13 +296,13 @@ h3, p { margin: 5px 0px; } -Read **[Sharing State Between Components](/learn/sharing-state-between-components)** to learn how to lift state up and keep components in sync. +Read **[Sharing State Between Components](/learn/sharing-state-between-components)** to learn how to lift State up and keep Components in sync. -## Preserving and resetting state {/*preserving-and-resetting-state*/} +## Preserving and Resetting State {/*preserving-and-resetting-state*/} -When you re-render a component, React needs to decide which parts of the tree to keep (and update), and which parts to discard or re-create from scratch. In most cases, React's automatic behavior works well enough. By default, React preserves the parts of the tree that "match up" with the previously rendered component tree. +When you re-render a Component, React needs to decide which parts of the tree to keep (and update), and which parts to discard or re-create from scratch. In most cases, React's automatic behavior works well enough. By default, React preserves the parts of the tree that "match up" with the previously rendered Component tree. However, sometimes this is not what you want. In this chat app, typing a message and then switching the recipient does not reset the input. This can make the user accidentally send a message to the wrong person: @@ -399,7 +399,7 @@ textarea { -React lets you override the default behavior, and *force* a component to reset its state by passing it a different `key`, like ``. This tells React that if the recipient is different, it should be considered a *different* `Chat` component that needs to be re-created from scratch with the new data (and UI like inputs). Now switching between the recipients resets the input field--even though you render the same component. +React lets you override the default behavior, and *force* a Component to reset its State by passing it a different `key`, like ``. This tells React that if the recipient is different, it should be considered a *different* `Chat` Component that needs to be re-created from scratch with the new data (and UI like inputs). Now switching between the recipients resets the input field--even though you render the same Component. @@ -496,13 +496,13 @@ textarea { -Read **[Preserving and Resetting State](/learn/preserving-and-resetting-state)** to learn the lifetime of state and how to control it. +Read **[Preserving and Resetting State](/learn/preserving-and-resetting-state)** to learn the lifetime of State and how to control it. -## Extracting state logic into a reducer {/*extracting-state-logic-into-a-reducer*/} +## Extracting State Logic into a Reducer {/*extracting-state-logic-into-a-reducer*/} -Components with many state updates spread across many event handlers can get overwhelming. For these cases, you can consolidate all the state update logic outside your component in a single function, called "reducer". Your event handlers become concise because they only specify the user "actions". At the bottom of the file, the reducer function specifies how the state should update in response to each action! +Components with many State updates spread across many event handlers can get overwhelming. For these cases, you can consolidate all the State update logic outside your Component in a single function, called "reducer". Your event handlers become concise because they only specify the user "actions". At the bottom of the file, the reducer function specifies how the State should update in response to each action! @@ -697,11 +697,11 @@ Read **[Extracting State Logic into a Reducer](/learn/extracting-state-logic-int -## Passing data deeply with context {/*passing-data-deeply-with-context*/} +## Passing Data Deeply with Context {/*passing-data-deeply-with-context*/} -Usually, you will pass information from a parent component to a child component via props. But passing props can become inconvenient if you need to pass some prop through many components, or if many components need the same information. Context lets the parent component make some information available to any component in the tree below it—no matter how deep it is—without passing it explicitly through props. +Usually, you will pass information from a parent Component to a child Component via props. But passing props can become inconvenient if you need to pass some prop through many Components, or if many Components need the same information. Context lets the parent Component make some information available to any Component in the tree below it—no matter how deep it is—without passing it explicitly through props. -Here, the `Heading` component determines its heading level by "asking" the closest `Section` for its level. Each `Section` tracks its own level by asking the parent `Section` and adding one to it. Every `Section` provides information to all components below it without passing props--it does that through context. +Here, the `Heading` Component determines its heading level by "asking" the closest `Section` for its level. Each `Section` tracks its own level by asking the parent `Section` and adding one to it. Every `Section` provides information to all Components below it without passing props--it does that through Context. @@ -795,15 +795,15 @@ export const LevelContext = createContext(0); -Read **[Passing Data Deeply with Context](/learn/passing-data-deeply-with-context)** to learn about using context as an alternative to passing props. +Read **[Passing Data Deeply with Context](/learn/passing-data-deeply-with-context)** to learn about using Context as an alternative to passing props. -## Scaling up with reducer and context {/*scaling-up-with-reducer-and-context*/} +## Scaling Up with Reducer and Context {/*scaling-up-with-reducer-and-context*/} -Reducers let you consolidate a component’s state update logic. Context lets you pass information deep down to other components. You can combine reducers and context together to manage state of a complex screen. +Reducers let you consolidate a Component’s State update logic. Context lets you pass information deep down to other Components. You can combine reducers and Context together to manage State of a complex screen. -With this approach, a parent component with complex state manages it with a reducer. Other components anywhere deep in the tree can read its state via context. They can also dispatch actions to update that state. +With this approach, a parent Component with complex State manages it with a reducer. Other Components anywhere deep in the tree can read its State via Context. They can also dispatch actions to update that State. @@ -1004,11 +1004,11 @@ ul, li { margin: 0; padding: 0; } -Read **[Scaling Up with Reducer and Context](/learn/scaling-up-with-reducer-and-context)** to learn how state management scales in a growing app. +Read **[Scaling Up with Reducer and Context](/learn/scaling-up-with-reducer-and-context)** to learn how State management scales in a growing app. -## What's next? {/*whats-next*/} +## What's Next? {/*whats-next*/} Head over to [Reacting to Input with State](/learn/reacting-to-input-with-state) to start reading this chapter page by page!