I want to use a keyDown event on a div in React. I do:
componentWillMount() { document.addEventListener(\"keydown\", this.onKeyPressed.bind(this));
You need to write it this way
If onKeyPressed is not bound to this, then try to rewrite it using arrow function or bind it in the component constructor. 0 讨论(0) 查看其它7个回答 发布评论: 提交评论 加载中... 验证码 看不清? 提交回复
If onKeyPressed is not bound to this, then try to rewrite it using arrow function or bind it in the component constructor.
onKeyPressed
this
constructor