0

** when I start the software for the first time the "items" state property is not valued. Not even setItems. If I try to reload a second time instead it is valued. How can I change the following code to make the status value also on first opening?**

enter image description here

How can I change the following code to make the status value also on first opening?

2
  • Unless I'm mistaken, I don't think you will ever be able to have items populated on first load, because you populate it from the result of an async function, which you call on first load. So you will always have to wait for that async function to finish before you have any items. Commented Nov 16, 2022 at 23:09
  • Remove the setItems([]) from your useEffect. You've already initialized items to an empty array in the useState([]) call. There is definitely a period of time where the items will be empty and attempt to render (though it may be very short). That will be an empty div with your current code. Recommend adding a loading message or gif conditionally shown. Commented Nov 17, 2022 at 14:05

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.