[Solved] Reactjs Async content render documentation [closed]


What you should do is to create a state that will contain the data from database, and you need to fill the state when “componentDidMount” or “useEffect” if you are using react Hooks.

react documentation of componentDidMount:

React componentDidMount

short example of what I meant:

import React, {useEffect, useState} from 'react'

const exampleApp = ()=>{
const [data,setData] = useState({})

useEffect(()=>{
   const data = await axios.get("yoururl");
   setData({...data})
},[])


return <div>{someMappingFunction(data)}</div>
}

solved Reactjs Async content render documentation [closed]