React useEffect with setTimeout to Understand the Setting of Data

13 days ago
7

The lecture explores the callback passed to the useEffect hook in React.

It uses a setTimeout to demonstrate that initially the data is in its initial state, until it is changed by the corresponding mutate function.

Once mutated, the state change signals React to render the component anew, resolving DOM discrepancies, and manifesting the new data to the user.

In the example, an empty list of messages is populated after some brief period of time, a simulation of what's like to make a request to a backend server to retrieve data.

Loading 1 comment...