The fetching is not going smoothly. I want images to show up at the same time. Here is how I have done it:
const [isLoading, setIsLoading] = useState(false)
useEffect(()=>{
setIsLoading(true)
fetch(url).then(res=>res.json()).then(data=>{
setPhoto(data)
setIsLoading(false)
})
},[url])
And then, I check, if isLoading is true, then I return "Loading" text. Else, the code should return the images page:
return (
<div className="App">
<header>.....
{isLoading?<p className={'text-5xl mt-11'}>Loading...</p>:<div className={'flex flex-wrap space-x-2 justify-around '}>
{photos?photos.hits.map((photo, index)=>{
return <img className={'m-5 h-80 rounded-2xl'} onClick={handleClickOnPicture} key={photo.webformatURL} src={photo.webformatURL}/>
}):""}