Please how do you I fetch data only once and never again when moving forth and back in react components using React Hooks. I simply want it on such a way that once the data is fetched for the first time in the component, it should not fetch again. Using an empty array [ ] in react hooks will make the component to fetch data once every single time we move to the component again. This is a sample code used in reacthooks to fetch the data only once. I simply want to fetch the data once and not again even when transitioning from page/component to component. This two links only fetch data once when navigating between pages. Thanks and hope to hear from you all http://www.favesound.de/ http://soundredux.io/
useEffect(() => {
const fetchData = async () => {
const result = await axios(url);
setData(result.data);
};
fetchData();
}, [url]);