I have a component that has a child component deep inside it.
In the click event of child component, I have this code:
onClick={(e) => {
// do something related to the deep child component
e.stopPropagation()
e.nativeEvent.stopPropagation()
}}
But this event still bubbles up and the onClick
handler of my parent component is still fired.
I read about SyntheticEvent and I also saw these questions. But none of them solved my problem:
ReactJS SyntheticEvent stopPropagation() only works with React events?
How to call stopPropagation in reactjs?
How can I prevent event bubbling in nested React components on click?