Dear friends, this block of codes was in the “answer” to the React challenge. submitMessage() is supposed to clear the input field and send what was typed in into “messages”.
However, if in setState, we first clear “input” to an empty string, wouldn’t the “this.state.input” in the next line be an empty string too? (Instead of what was previously typed in).
If anyone has an answer to this question, I would really appreciate it!
messages: […this.state.messages, this.state.input]