T
T
Tyu Vyacheslav2021-06-10 09:51:07
React
Tyu Vyacheslav, 2021-06-10 09:51:07

How can one send a request and write to the pre-render state?

Good afternoon. I send a request and write it to the state, but initially the state = empty object and when the page tries to render something from this state, it throws a Null error. how to make it wait for a response to a request, and then render the page?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kentavr16, 2021-06-10
@Hurricane-99

Generally this is done with componendidmount or the useEffect hook. For a more specific answer, please provide the code

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question