Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 230092

Stop click propagation in accordion header

$
0
0

React and synthetic events strike again!

TL;DR, the click event from your button isn’t a real click event, but one that react will dispatch in place of a native click. So your stopProp call won’t actually work.

What you can do is wire up something like this…

const button = useRef(null);
  useEffect(() => {
    if (button.current) {
      (button.current as HTMLElement).onclick = (e) => {
        console.log('handler stop');
        e.stopPropagation()
      } 
    }
  }, [button])

Where the button will have a native click handler.

Here’s a stackoverflow post to explain why in detail


Viewing all articles
Browse latest Browse all 230092

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>