A
A
Art0052020-12-16 17:08:03
React
Art005, 2020-12-16 17:08:03

How to get data before component processing?

How to insert data from an asynchronous request into a state if work with the response from an asynchronous task begins only after all synchronous tasks have been processed. That is, the component is displayed without data. Can I have an example code on how to fill the state before displaying the component?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Makarov, 2020-12-17
@Art005

Read about the useEffect hook You pass the
first argument to the function The
second you pass the parameters on which it depends, or you leave an empty array so that it works once

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question