Cannot read property 'style' of null on else statement

im using react the if statemant works fine but when i use else it gives this error how can i fix it.


it’s impossible to help you if you don’t show your code, you have already been told this

 if(chosenColor === "images/red-front.png"){
    document.getElementById("bu").style.display = "none";
  } else{
    document.getElementById("bu").style.display = "block";

How is anyone supposed to tell from that code snipped why your code isn’t working?

And why do you even use React when you use vanilla JS for your logic? It makes no sense at all. I’m not telling you what to do, you can keep on copying code and trying to fix it so it does what you want, but how on earth are you ever going to deploy anything remotely acceptable if you don’t even understand the basics of what you’re doing?

slow down bro i just asked a question if it upsets you this much you can just not do anything.

if it says that it can’t read property of null, then this is null - no element was found

Dude, nevermind, do whatever pleases you but be so kind and stop asking questions with no context, so we have to beg every time for some more code before it’s possible to help you.