Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fires multiple times for multiple instances #144

Open
matthew-dean opened this issue Feb 19, 2018 · 4 comments
Open

Fires multiple times for multiple instances #144

matthew-dean opened this issue Feb 19, 2018 · 4 comments

Comments

@matthew-dean
Copy link

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?

@matthew-dean matthew-dean changed the title Fires for multiple instances Fires multiple times for multiple instances Feb 19, 2018
@ayrton
Copy link
Owner

ayrton commented Aug 22, 2018

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.

@gforge
Copy link
Contributor

gforge commented Sep 7, 2018

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

@vkolova
Copy link

vkolova commented Sep 14, 2018

@ayrton Is there any chance to add option to disable this? Moving the KeyHandler is not possible for me.

@ayrton
Copy link
Owner

ayrton commented Sep 16, 2018

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants