Skip to content

Commit 7e8db7e

Browse files
authored
Update example for calculating fullName from state
Clarify the example of updating state based on props or state in the documentation.
1 parent 9b68be9 commit 7e8db7e

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ To help you gain the right intuition, let's look at some common concrete example
3434

3535
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:
3636

37+
```js {expectedErrors: {'react-compiler': [8]}} {5-9}
3738
```js {5-9}
3839
function Form() {
3940
const [firstName, setFirstName] = useState('Taylor');

0 commit comments

Comments
 (0)