+ 6

How to stop element inside a functional component from bubbling up to the body element? [Solved]

In the following code if you click on body the element disappears but I want that if I click on element , particularly those 3 dots it shudn't disappear and I tried using e.stopPropagation() but it doesn't work for some reason that I don't understand https://code.sololearn.com/WP99GA8yDcg5/?ref=app

2nd Aug 2020, 4:25 PM
Abhay
Abhay - avatar
5 Respuestas
0
You can see what element was clicked on with e.target. using e.target.id you can identify then handle what functions you want to run accordingly.
2nd Aug 2020, 6:16 PM
JME
0
JME it prints nothing
2nd Aug 2020, 8:16 PM
Abhay
Abhay - avatar
0
It will print nothing if the element has no id
2nd Aug 2020, 8:20 PM
JME
0
JME oh yea ,thks I thought id meant something else!! And it definitely targets that element on click as I have looked out and even styled the dots but stopPropagation() doesn't works just
2nd Aug 2020, 8:32 PM
Abhay
Abhay - avatar