My app fetches some data from a server using useEffect and passes it as a prop to a child component. I would like to pause the rendering of the child component until the data is completely fetched and loaded into a state. How can I achieve this?
My code(simplified):
const App = () => {
const [data, setData] = useState(undefined)
useEffect(async () => {
const fetchedData = await getDataFromServer()
setData(fetchedData)
}, [])
return (
<div>
<ChildComponent data={data} /> // How to pause rendering until data != undefined?
</div>
)
}