I'm trying to debounce sending a Redux Action from an input change in React.
const debouncedSubmit = debounce(() => dispatch(new TaskAnswerSubmit({index: props.index, text: answer})), 1000)
function onChange(e){
setAnswer(e.target.value)
debouncedSubmit()
}
This is delaying sending the actions, but still sending one for every keypress. I want to wait a second after the typing finishes before sending the action just once.
What am I doing wrong here?