You get a bonus - 1 coin for daily activity. Now you have 1 coin

What is the purpose of the callback function as an argument to setState() in REACT?

Practice



The callback function is invoked when setState has finished and the component has been rendered. Since

setState()
is asynchronous, the callback function is used for any follow-up action.

Note. It is recommended to use a lifecycle method rather than this callback function.

 

  1. setState({ name: 'John' }, () => console.log('The name has updated and component re-rendered'))
  2.  

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Scripting client side JavaScript, jqvery, BackBone"

Terms: Scripting client side JavaScript, jqvery, BackBone