jaywcjlove / react-hotkeys

React component to listen to keydown and keyup keyboard events, defining and dispatching keyboard shortcuts.

Home Page:https://jaywcjlove.github.io/react-hotkeys/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

请问对象handle中的key和shortcut有什么区别

weidapao opened this issue · comments

 if (this.props.keyName.indexOf(this.handle.shortcut) < 0) return;

请问这句话是什么作用,感觉不会出现小于0的情况。

还想问一个问题,为什么不把isKeyDown,handle等写在组件的state上

@weidapao

第一个问题有可能出现的。

第二个问题,state 有延迟,使用 state 需要维护一个 componentWillReceiveProps 生命周期函数,个人觉得这个不需要数据绑定功能,所以没有使用 state

感谢回答,还有一点,handle的key和shortcut属性有啥区别