You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've found that if the parent components props/state changes when an event is fired it will re-trigger the same event, i.e. firing twice. To be more specific, it happened when a new react-key-handler component with the same key binding was created on a different element. To illustrate the components
when I pressed 2 the button one would disappear and the keys would with new bindings:
[button two, key 1], [button three, key 2]
I've solved this by adding a setTimeout(.., 0) to the call. This could possibly be activated through a prop that wraps the onKeyHandle in a setTimeout function.
The text was updated successfully, but these errors were encountered:
gforge
changed the title
Fires twice if props/state changes du to update
Fires twice if props/state changes causes re-mapping of the fired key
Sep 17, 2018
I've found that if the parent components props/state changes when an event is fired it will re-trigger the same event, i.e. firing twice. To be more specific, it happened when a new
react-key-handler
component with the same key binding was created on a different element. To illustrate the components[button one, key 1], [button two, key 2], [button three, key 3]
when I pressed
2
thebutton one
would disappear and the keys would with new bindings:[button two, key 1], [button three, key 2]
I've solved this by adding a
setTimeout(.., 0)
to the call. This could possibly be activated through a prop that wraps theonKeyHandle
in asetTimeout
function.The text was updated successfully, but these errors were encountered: