在react 的事件中使用SyntheticEvent 就会出现下面的报错
<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
网友评论