声明式的处理React的事件 – react-event

老栗子 2019-09-12 12:21:40
React Event 声明式的处理React的事件 Example import enhanceWithEvent from '@pinnacleio/react-event' class HelloWorld extends Component { handleEvent() { /* Do whatever you want 🙂 */ } render() { return <div /> } } // This component calls `handleEvent` method when `mousedown` is fired anywhere. const Foo = enhanceWithEvent('mousedown')(HelloWorld) // This component calls `handleEvent` method when `mousedown` is fired inside it. const Bar = enhanceWithEvent('mousedown', { inside: true })(HelloWorld) // This component calls `handleEvent` method when `mousedown` is fired outside of it. const Baz = enhanceWithEvent('mousedown', { outside: true })(HelloWorld) API Our component must define methodhandleEvent()in order for enhancer to work, otherwise nothing will happen. enhanceWithEvent( events: String | Array<String>, options: Object, ): HigherOrderComponent Parameter Description Example Default Value events Event type(s) to listen for. ‘mousedown’, [‘mousedown’, ‘touchstart’] Nil options Where event will be accepted. { outside: true }, { inside: true } {}
...全文
14 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

433

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧