1

I'm new to react and I wanted to make a button that when clicked opens up a sidedrawer that will close once you click on the backdrop that opens up as well. I have gotten this to work (sometimes) for some reason when I try to get the event.target.getAttribute it sometimes becomes null and sometimes not.

like this:

consol.log output

(consol.log output)

The button component that I click looks like this:

Button component

my backdrop looks like this:

BackDrop component

and this is the function that is called when I click looks like:

handeClick

(I have tried to only use const {name} = event.target.name but this only works for the button and I always get name = undefined when I click on the backdrop). Can anyone help me understand why this is happening? Thanks!

Nikos Hidalgo
  • 3,666
  • 9
  • 25
  • 39

0 Answers0