I am trying to get data from the link below by using fetch and store it in 'dataStore' and display.
However, it keeps giving me an error and I believe my code tries to show the data before it is stored in 'dataStore'. I'm new to coding. tried to research and find a solution past weeks but couldn't. Please help. Thank you!
import "./App.css";
import { useEffect, useState } from "react";
function App() {
let [dataStore, setDataStore] = useState([]);
useEffect(() => {
fetch(
"https://raw.githubusercontent.com/Biuni/PokemonGo-Pokedex/master/pokedex.json"
)
.then((response) => response.json())
.then((result) => {
const { pokemon } = result;
setDataStore(pokemon);
})
.catch((error) => console.log(error));
}, []);
return (
<div>
<div>{dataStore[0].name}</div>
</div>
); // ending div
} //ending line
export default App;