-
Notifications
You must be signed in to change notification settings - Fork 160
Description
Hello,
First thank you for your package.
Since the 1.1.4 release, and especially this Pull Request (https://github.com/greena13/react-hotkeys/pull/101/files), there is a breaking change regarding event propagation to parent's handler.
Before this release, a hotkey defined in a child component AND in a root component was only triggered once (by the most nested component). But now, they are always both triggered (nested component AND root component).
I guess this happens because we create a new handler on each render() (and so hasChanged(handlers, prevHandlers)
is always true) (see: https://github.com/greena13/react-hotkeys/pull/101/files#diff-5f147d6760a1bc2314f409768a38984fR247).
It means that your example in the README won't stop propagation to parent because a new handler is created on each render:
const MyNode = React.createClass({
render() {
const handlers = {
'deleteNode': this.deleteNode
};
return (
<HotKeys handlers={handlers}>
Node contents
</HotKeys>
);
}
});
Is it a (new) expected behavior ? If its is, shouldn't we mark this PR as a breaking change ?
We had to rollback to previous release to fix this issue, and I guess we're not the only one to create a new handler on each render (bad idea though, but a breaking change nevertheless)