From 28aacc64b5637ac0c7bdc8f024791806189c2768 Mon Sep 17 00:00:00 2001 From: Evgenii Panaite <48415020+Jonnius00@users.noreply.github.com> Date: Tue, 25 Mar 2025 17:49:09 +0100 Subject: [PATCH 1/2] Update intro-react.md extented explanation why state denoted as a const --- docs/intro-react.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/intro-react.md b/docs/intro-react.md index f30c4c037f1..30152d605b7 100644 --- a/docs/intro-react.md +++ b/docs/intro-react.md @@ -445,7 +445,8 @@ Now, when someone presses the button, `onPress` will fire, calling the `setIsHun /> ``` -> 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`. +> 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. +> 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`. Finally, put your cats inside a `Cafe` component: From bda9a0c84a354f55d52127437c640208e62c2c9c Mon Sep 17 00:00:00 2001 From: Evgenii Panaite <48415020+Jonnius00@users.noreply.github.com> Date: Mon, 30 Jun 2025 13:55:16 +0200 Subject: [PATCH 2/2] Update docs/intro-react.md Co-authored-by: Riccardo Cipolleschi --- docs/intro-react.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/intro-react.md b/docs/intro-react.md index 30152d605b7..03870c11723 100644 --- a/docs/intro-react.md +++ b/docs/intro-react.md @@ -445,7 +445,7 @@ Now, when someone presses the button, `onPress` will fire, calling the `setIsHun /> ``` -> 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. +> 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 the object, that contains the state and the function to update it, will not change. > 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`. Finally, put your cats inside a `Cafe` component: