I have a function (startLoad()) which is executed every time some of my data changes (i.e. dataMayChange).
Within this method i want to execute some GraphQL Queries (i.e. fireQuery1, fireQuery2, ...).
Every time when my dataMayChange changes, i want to stop executing startLoad and execute it again from the beginning. This way i want to prevent the old queries before my dataMayChange has changed to be fired.
Here is my Code:
React.useEffect(() => {
startLoad()
// eslint-disable-next-line
}, [dataMayChange])
const startLoad = async() => {
await fireQuery1
await fireQuery2
await fireQuery3
await fireQuery4
}
Does anyone have an idea how i can achieve this behavior?