Only use error boundaries for recovering from unexpected exceptions; don’t try to use them for control flow.For more details, see enqueues changes to the component state and tells React that this component and its children need to be re-rendered with the updated state.Use this pattern with caution because it often causes performance issues.It can, however, be necessary for cases like modals and tooltips when you need to measure a DOM node before rendering something that depends on its size or position. Note that React will call this method even if the props have not changed, so make sure to compare the current and next values if you only want to handle changes.
If you need to load data from a remote endpoint, this is a good place to instantiate the network request.
a network request may not be necessary if the props have not changed).
is invoked immediately before a component is unmounted and destroyed.
is also asynchronous, and multiple calls during the same cycle may be batched together.
For example, if you attempt to increment an item quantity more than once in the same cycle, that will result in the equivalent of: Subsequent calls will override values from previous calls in the same cycle, so the quantity will only be incremented once.