can someone explain me why this does loop forever when I place it in the app's (functional component)
const [data, setData] = useState()
const fetchData = async() => {
const queryResults = await axios.post(
Constants.GRAPHQL_API, {
query: Constants.GET_TEST
}
);
const result = queryResults.data.data
setData(result)
};
fetchData();
console.log(data);
Top comments (2)
I think I got it working, I place this in a separate function component, and called it from app.js
I did place it in a use effect then I can kill the loop, but I want to be able to call it on login