Lesson 72
Clear Text Field After Successful Submission in React App
The lecture goes over how to empty the text field used to type in a new message, after the user clicks the send button and it succeeds posting.
The mutate function obtained from the call to useState can be used to set the new message value to empty string.
Because the input type text is controlled with the value prop, the change in React state for new message causes the component to render again, using the new empty value.
Various questions are addressed, such as fetching data as a side effect using the useEffect hook.
Equivalent lifecycle methods in the old React way of class components are also mentioned, such as componentDidMount and componentDidUpdate.
No comments yet (loading...)
No comments yet (loading...)
Did you like the lesson? 😆👍
Consider a donation to support our work: