Skip to content

Commit 28aacc6

Browse files
authored
Update intro-react.md
extented explanation why state denoted as a const
1 parent 71b23ed commit 28aacc6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

docs/intro-react.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,8 @@ Now, when someone presses the button, `onPress` will fire, calling the `setIsHun
445445
/>
446446
```
447447

448-
> You might’ve noticed that although `isHungry` is a [const](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/const), it is seemingly reassignable! What is happening is when a state-setting function like `setIsHungry` is called, its component will re-render. In this case the `Cat` function will run again—and this time, `useState` will give us the next value of `isHungry`.
448+
> You might’ve noticed that although `isHungry` is a [const](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/const), it is seemingly reassignable! The `const` keyword here does not mean that the state itself is immutable. rather, it means that the reference to an object [ ] (contains the state and the function to update it) will not change.
449+
> What is happening is when a state-setting function like `setIsHungry` is called, its component will re-render. In this case the `Cat` function will run again—and this time, `useState` will give us the next value of `isHungry`.
449450
450451
Finally, put your cats inside a `Cafe` component:
451452

0 commit comments

Comments
 (0)