简体   繁体   中英

firing onClick handler when click on component inside it

when i click on button section its working fine, but the problem is when i click on Component section inside button then my function not firing

this.resetStates = this.resetStates.bind(this) ;

<button onClick={this.resetStates}>
    <NumberFormat/>
</button>

I use a CSS lot of the time with similar problems in svg. It might help you here too. You can put pointer-events: none to the inner component. This way the inner component is not clickable and every click event come to the outer button component. For example:

<button onClick={this.resetStates}>
  <div style={{pointerEvents: 'none'}}>
     <NumberFormat/>
  </div>
</button>

Is it helping you?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM