The steps are discussed below.
Read moreCan we directly update state in React?
One should never update the state directly because of the following reasons: If you update it directly, calling the setState() afterward may just replace the update you made. When you directly update the state, it does not change this.
Read more