Browse Source

[Beta] Update the effect with a capital letter (#5027)

main
zqran 2 years ago
committed by GitHub
parent
commit
7e8447aa64
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      beta/src/content/learn/escape-hatches.md
  2. 2
      beta/src/content/learn/manipulating-the-dom-with-refs.md
  3. 2
      beta/src/content/learn/synchronizing-with-effects.md
  4. 2
      beta/src/content/learn/you-might-not-need-an-effect.md

2
beta/src/content/learn/escape-hatches.md

@ -602,7 +602,7 @@ Read **[Separating Events from Effects](/learn/separating-events-from-effects)**
</LearnMore>
## Removing effect dependencies {/*removing-effect-dependencies*/}
## Removing Effect dependencies {/*removing-effect-dependencies*/}
When you write an Effect, the linter will verify that you've included every reactive value (like props and state) that the Effect reads in the list of your Effect's dependencies. This ensures that your Effect remains synchronized with the latest props and state of your component. Unnecessary dependencies may cause your Effect to run too often, or even create an infinite loop. The way you remove them depends on the case.

2
beta/src/content/learn/manipulating-the-dom-with-refs.md

@ -489,7 +489,7 @@ In general, you [don't want](/learn/referencing-values-with-refs#best-practices-
React sets `ref.current` during the commit. Before updating the DOM, React sets the affected `ref.current` values to `null`. After updating the DOM, React immediately sets them to the corresponding DOM nodes.
**Usually, you will access refs from event handlers.** If you want to do something with a ref, but there is no particular event to do it in, you might need an effect. We will discuss effects on the next pages.
**Usually, you will access refs from event handlers.** If you want to do something with a ref, but there is no particular event to do it in, you might need an Effect. We will discuss effects on the next pages.
<DeepDive title="Flushing state updates synchronously with flushSync">

2
beta/src/content/learn/synchronizing-with-effects.md

@ -39,7 +39,7 @@ Here and later in this text, capitalized "Effect" refers to the React-specific d
## You might not need an Effect {/*you-might-not-need-an-effect*/}
**Don't rush to add Effects to your components.** Keep in mind that Effects are typically used to "step out" of your React code and synchronize with some *external* system. This includes browser APIs, third-party widgets, network, and so on. If your effect only adjusts some state based on other state, [you might not need an Effect.](/learn/you-might-not-need-an-effect)
**Don't rush to add Effects to your components.** Keep in mind that Effects are typically used to "step out" of your React code and synchronize with some *external* system. This includes browser APIs, third-party widgets, network, and so on. If your Effect only adjusts some state based on other state, [you might not need an Effect.](/learn/you-might-not-need-an-effect)
## How to write an Effect {/*how-to-write-an-effect*/}

2
beta/src/content/learn/you-might-not-need-an-effect.md

@ -32,7 +32,7 @@ To help you gain the right intuition, let's look at some common concrete example
### Updating state based on props or state {/*updating-state-based-on-props-or-state*/}
Suppose you have a component with two state variables: `firstName` and `lastName`. You want to calculate a `fullName` from them by concatenating them. Moreover, you'd like `fullName` to update whenever `firstName` or `lastName` change. Your first instinct might be to add a `fullName` state variable and update it in an effect:
Suppose you have a component with two state variables: `firstName` and `lastName`. You want to calculate a `fullName` from them by concatenating them. Moreover, you'd like `fullName` to update whenever `firstName` or `lastName` change. Your first instinct might be to add a `fullName` state variable and update it in an Effect:
```js {5-9}
function Form() {

Loading…
Cancel
Save