Skip to content

Commit

Permalink
Update synchronizing-with-effects.md (#6856)
Browse files Browse the repository at this point in the history
* Update synchronizing-with-effects.md

Currently documentation says:

By default, your Effect will run after every render.

Which is in contrast with another section of the same page where it says:

Effects run at the end of a commit after the screen updates

* Update src/content/learn/synchronizing-with-effects.md

---------

Co-authored-by: Ricky <[email protected]>
  • Loading branch information
segmentationfaulter and rickhanlonii committed May 10, 2024
1 parent f9b9b66 commit 4f1d985
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/content/learn/synchronizing-with-effects.md
Expand Up @@ -45,7 +45,7 @@ Here and later in this text, capitalized "Effect" refers to the React-specific d

To write an Effect, follow these three steps:

1. **Declare an Effect.** By default, your Effect will run after every render.
1. **Declare an Effect.** By default, your Effect will run after every [commit](/learn/render-and-commit).
2. **Specify the Effect dependencies.** Most Effects should only re-run *when needed* rather than after every render. For example, a fade-in animation should only trigger when a component appears. Connecting and disconnecting to a chat room should only happen when the component appears and disappears, or when the chat room changes. You will learn how to control this by specifying *dependencies.*
3. **Add cleanup if needed.** Some Effects need to specify how to stop, undo, or clean up whatever they were doing. For example, "connect" needs "disconnect", "subscribe" needs "unsubscribe", and "fetch" needs either "cancel" or "ignore". You will learn how to do this by returning a *cleanup function*.

Expand Down

0 comments on commit 4f1d985

Please sign in to comment.