From 7939ec7de81cc214201f0167abd393484a744ac1 Mon Sep 17 00:00:00 2001 From: Punith1117 Date: Tue, 18 Feb 2025 14:01:27 +0530 Subject: [PATCH 1/3] clarify alert message behavior in issue #7494 Reworded the explanation regarding the alert message in the documentation to better describe its behavior. The alert shows the previously entered name, with an initial value set to an empty string. --- src/content/learn/state-a-components-memory.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/learn/state-a-components-memory.md b/src/content/learn/state-a-components-memory.md index 75a1fd0b91e..5f23099f573 100644 --- a/src/content/learn/state-a-components-memory.md +++ b/src/content/learn/state-a-components-memory.md @@ -1452,7 +1452,7 @@ If your linter is [configured for React](/learn/editor-setup#linting), you shoul #### Remove unnecessary state {/*remove-unnecessary-state*/} -When the button is clicked, this example should ask for the user's name and then display an alert greeting them. You tried to use state to keep the name, but for some reason it always shows "Hello, !". +When the button is clicked, this example should ask for the user's name and then display an alert greeting them. You tried to use state to keep the name, but for some reason it always shows "Hello, [value]!", where value is the previous input, initially set to an empty string. To fix this code, remove the unnecessary state variable. (We will discuss about [why this didn't work](/learn/state-as-a-snapshot) later.) From e776fda07c3adcaea11d8be722735e84b224539d Mon Sep 17 00:00:00 2001 From: Ricky Date: Tue, 18 Feb 2025 09:37:55 -0500 Subject: [PATCH 2/3] Update src/content/learn/state-a-components-memory.md --- src/content/learn/state-a-components-memory.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/learn/state-a-components-memory.md b/src/content/learn/state-a-components-memory.md index 5f23099f573..a372fb794ec 100644 --- a/src/content/learn/state-a-components-memory.md +++ b/src/content/learn/state-a-components-memory.md @@ -1452,7 +1452,7 @@ If your linter is [configured for React](/learn/editor-setup#linting), you shoul #### Remove unnecessary state {/*remove-unnecessary-state*/} -When the button is clicked, this example should ask for the user's name and then display an alert greeting them. You tried to use state to keep the name, but for some reason it always shows "Hello, [value]!", where value is the previous input, initially set to an empty string. +When the button is clicked, this example should ask for the user's name and then display an alert greeting them. You tried to use state to keep the name, but for some reason the first time it shows "Hello, !", and then "Hello, {name}!" with the previous input every time after. To fix this code, remove the unnecessary state variable. (We will discuss about [why this didn't work](/learn/state-as-a-snapshot) later.) From ce2ef507810d0583341df06c976e838d899a5336 Mon Sep 17 00:00:00 2001 From: Ricky Date: Tue, 18 Feb 2025 09:40:51 -0500 Subject: [PATCH 3/3] Update src/content/learn/state-a-components-memory.md --- src/content/learn/state-a-components-memory.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/learn/state-a-components-memory.md b/src/content/learn/state-a-components-memory.md index a372fb794ec..73d46bdab86 100644 --- a/src/content/learn/state-a-components-memory.md +++ b/src/content/learn/state-a-components-memory.md @@ -1452,7 +1452,7 @@ If your linter is [configured for React](/learn/editor-setup#linting), you shoul #### Remove unnecessary state {/*remove-unnecessary-state*/} -When the button is clicked, this example should ask for the user's name and then display an alert greeting them. You tried to use state to keep the name, but for some reason the first time it shows "Hello, !", and then "Hello, {name}!" with the previous input every time after. +When the button is clicked, this example should ask for the user's name and then display an alert greeting them. You tried to use state to keep the name, but for some reason the first time it shows "Hello, !", and then "Hello, [name]!" with the previous input every time after. To fix this code, remove the unnecessary state variable. (We will discuss about [why this didn't work](/learn/state-as-a-snapshot) later.)