Browse Source

Fixed the challenge 4 expected output when initial state of "showForm" changed to false. Since there can be only one empty message when the initial state of "showForm" changed from true to false. (#5071)

main
kaushalyap 3 years ago
committed by GitHub
parent
commit
5bcae4f884
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      beta/src/content/learn/you-might-not-need-an-effect.md

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

@ -1594,7 +1594,7 @@ button {
This `Form` component lets you send a message to a friend. When you submit the form, the `showForm` state variable is set to `false`. This triggers an Effect calling `sendMessage(message)`, which sends the message (you can see it in the console). After the message is sent, you see a "Thank you" dialog with an "Open chat" button that lets you get back to the form.
Your app's users are sending way too many messages. To make chatting a little bit more difficult, you've decided to show the "Thank you" dialog *first* rather than the form. Change the `showForm` state variable to initialize to `false` instead of `true`. As soon as you make that change, the console will show that an empty message was sent twice. Something in this logic is wrong!
Your app's users are sending way too many messages. To make chatting a little bit more difficult, you've decided to show the "Thank you" dialog *first* rather than the form. Change the `showForm` state variable to initialize to `false` instead of `true`. As soon as you make that change, the console will show that an empty message was sent. Something in this logic is wrong!
What's the root cause of this problem? And how can you fix it?

Loading…
Cancel
Save