Purpose of callback function as an argument of setState
SetState is an asynchronous method. Asynchronous means that the remaining code will get executed while the current action is being performed. Whereas synchronous code will block the code execution while the current action is being performed. So, if you want an action to be performed only after the state has been updated you can make use of a call back function. This callback function is put as an argument to setState the method. This is the exact purpose of defining a callback function as an argument of setState.
What is the purpose of callback function as an argument of setState event ?
In React, the purpose of callback function as an argument of setState event is to execute the code after the data in the state is modified.