-
Notifications
You must be signed in to change notification settings - Fork 160
Closed
Description
I love HOCs, and I believe it would be amazing if picking up this library was as simple as doing this:
const App = props => <MyFullApp />
// Magic, without changing anything but this line in my entire massive code base,
// space bar suddenly triggers something :)
export default withHotKeys({ handlers: { space: () => console.log('it works!') }, global: true })(App);
Or even pass it as the second argument, in the componentProps
of the HOC, but that does not seem to work (Am I doing something wrong?).
To be honest, I think that the API of the HOC is bad, since both arguments are passed down to <HotKeys />
, in my opinion, it should simply be withHotKeys( componentProps: Object )
to which you can pass all the props you want, including handlers
. Sadly, this would be a breaking change, but I believe simpler, and better design.
Also, global
would be a shortcut for focused: true, attach: window
, which I had to dig for in the issues to find out.
Metadata
Metadata
Assignees
Labels
No labels