Home.jsx
useEffect(() => {
fetch(
`https://api.openweathermap.org/data/2.5/onecall?lat=11&lon=11&exclude=hourly,minutely&units=metric&appid=${process.env.REACT_APP_API_KEY}`
)
.then((res) => res.json())
.then((data) => setData(data));
});
return (
<div className="home">
<DataContext.Provider value={{ data }}>
<section className="main-section">
<Navbar />
<Toprow />
</section>
<section className="side-section">
<Aside />
</section>
</DataContext.Provider>
</div>
);
}; ```
** top row component where i am using the data**
const { data } = useContext(DataContext);
and then consolelogging it giving this error
Consider adding an error boundary to your tree to customize error handling behavior. Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries.
Toprow.jsx:52 Uncaught TypeError: Cannot read properties of undefined (reading 'temp') at Toprow (Toprow.jsx:52:1)
check website at weatherflu-react.netlify.app
and i check this flow which i think says this thing better but i dont know what to do
https://stackoverflow.com/questions/72033780/flaky-errors-when-fetching-rendering-data-using-react-hooks