This probably seems like an odd question, but what I'm trying to do is create a simple search field in React. I don't want to make an API call every time the search field is changed, but only if a certain time e.g 500ms has passed since the last state change to ensure that the user isn't typing anymore.
I wanted to do this using the setTimeout function, but I can't find a way to find out during rendering if a state change has been made or something has been added on top of the call stack.
So is there a way to check if there is another render scheduled during rendering?
Something like this:
export default function(){
setTimeout(() => {CHECK IF THERE'S BEEN A STATE CHANGE, IF NOT FETCH API}, 500)
}