react-key-handler
react-key-handler copied to clipboard
Fires multiple times for multiple instances
I have a component that contains this:
<KeyHandler
keyEventName={KEYPRESS}
keyValue='Enter'
onKeyHandle={onKeyHandler}
/>
So, when i make multiple instances of my React component that contains this, I'm finding that onKeyHandler fires for ALL when ONE of them receives a keypress event. Any idea why this is happening or how to prevent it?
Firing the key handler for each component is the expected behaviour, if this is unwanted you should move the KeyHandler up one (or more) level(s) and pass the necessary props to your child components.
I've just noticed that I sometimes get a double fire when there is a prop change due to the update, solved this through a setTimeout
@ayrton Is there any chance to add option to disable this? Moving the KeyHandler is not possible for me.
@gforge that seems a separate issue, could you create a separate issue? @vkolova I am not sure I understand how/why can you explain please