react合成事件null問題
Warning: This synthetic event is reused for performance reasons. If you're seeing this, you're accessing the property **nativeEvent** on a released/nullified synthetic event. This is set to null. If you must keep the original synthetic event around, use event.persist(). See https://fb.me/react-event-pooling for more information.
這個話的意思是這個回調(diào)之前nativeEvent被刪除了,你需要引用它。
react官網(wǎng)是這樣說的
console.log(event); // => nullified object.
console.log(event.type); // => "click"
所以, 用的時候可以直接取出來
let {x, y} = event.nativeEvent.contentOffset
console.log(x) //水平滾動距離
console.log(y) //垂直滾動距離
OK
之所以寫這個呢, 我特么我復(fù)制別的博文代碼, 結(jié)果取不到值。一打印發(fā)現(xiàn)nativeEvent是空的, excuse me?
然后看到了提示, 哈哈 就是就是事件合成問題。
然后既然是這個問題, 這個寫法也沒錯啊, 但是不行, 估計是里面的值錯了, 還是去看官方文檔。

嗯, 大概沒錯, 就是一個單詞錯了。
--END--