0

I’m having issues displaying data from an API. I’m using React hooks to help me get the data. My code looks somewhat similar to the example function I just created. My component is a pop up modal so it will only render once the pop up is open. When the modal is opened the component will render but the info variable in state will always be the empty object. Does anyone know why my state is not updating to the api data and is an empty object on render?

export const ReactFunction = () => {

const [info, setInfo] = useState({})

useEffect(() => {
   GetApiData().then(data=>setInfo(data))
},[])

return (
<>
   <div>{info}</div>
</>
Anonymous Asked question May 14, 2021