how to handle event listeners in react