react 事件报错Switch

_handleChangeSwitch(active) {
    this.props.changeSwitch({
      type: CHANGE_WARRANTY,
      active
    })
}
<Switch
    checked={needExtInsurance}
    onChange={this._handleChangeSwitch}
/>

active获取到的不是Boolean值而是一个对象
报错如下:
index.js:1375 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-poo... for more information.

阅读 1.7k
1 个回答

根据题主你给的代码,给出以下猜测:
switch组件绑定的checked的值和onChange存储的值不是同一个,或许应该是这样的

_handleChangeSwitch(active) {
    this.props.changeSwitch({
      type: CHANGE_WARRANTY,
      needExtInsurance: active
    })
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题