在react 的事件中使用SyntheticEvent 就會出現(xiàn)下面的報錯
<input
onChange={async e => {
await foo()
...
}}
/>
Warning: This synthetic event is reused for performance reasons. If you're seeing this, you're accessing the property target 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.
那么怎么解決呢?
<input
onChange={async e => {
e.persist()
await foo()
...
}}
/>
詳情可以看官方文檔https://reactjs.org/docs/events.html