을 던지는 유지에서 mousemove 이벤트를 스로틀, 나는 방법을 구축하기 위해 아래의 도움말을 따라,하지만 작동하지 않습니다 다음은 Perform debounce in React.jsReact.js 내가 MouseMove 이벤트 이벤트를 스로틀 할 필요가 event.persist() 오류
내 코드 (http://jsbin.com/binesofepo/edit?js,console,output는) :
버전을 반응의 나 : "15.0.2"경고 : 당신이
tool__body
에 MouseMove 이벤트를 유지하는 경우class Tool extends Component { constructor(props) { super(props); this._onMouseMove = _.throttle(this._onMouseMove.bind(this), 1000) } render() { return ( <div ref="tool" className="tool"> <div ref="toolBody" className="tool__body" onMouseMove={this._onMouseMove}></div> </div> ) } _onMouseMove(e) { e.persist() console.log(e.screenX) } }
, 그것은 아래의 경고를 많이 얻을 것이다이 S 즐거운 이벤트는 성능상의 이유로 재사용됩니다. 이것을보고있는 경우 공개/무효 합성 이벤트에서
screenX
속성에 액세스하고 있습니다. null로 설정됩니다. 원래 합성 이벤트를 유지해야하는 경우 event.persist()를 사용하십시오. 자세한 정보는 fb.me /react-event-pooling을 참조하십시오.
가 잘 작동하지 않습니다 e.persist()
을 보인다. 어떤 생각? : D
나에게 꽤 유용한 오류 메시지가 표시됩니다. 추천 링크 https://facebook.github.io/react/docs/events.html#event-pooling을 따르셨습니까? –
예, 그래서''_onMouseMove'에'e.persist()'를 추가했지만 작동하지 않습니다. – twxia