I'm moving over to functional components from class components and having trouble handling this scenario. This component's state can be updated by 2 different event listeners: key down or mouseover. I want to trigger a callback after the state is updated ONLY if updated by key down. Any way to do this?
const handleMouseOver = e => {
setSelection(e.target.value)
}
const handleDownArrowKeyDown = () => {
...
setSelection(selection + 1)
}
useEffect(() => {
// Only execute below if selection state was updated by handleDownArrowKeyDown
...
}, [selection])