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)
The button component that I click looks like this:
my backdrop looks like this:
and this is the function that is called when I click looks like:
(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!