Brad Farberman
Feb 19, 2021

Let’s Make Text Disappear in React!

Kind of like this!

Hey, you! Yes, you! Want to make text disappear in React? Let’s do it.

First, we can set something like “show” to true in state.

Then let’s write a textDisappear function. When we set state, we’ll set show to the opposite of show using a bang operator.

Next, we’ll write out a ternary. When we click on the button, it will say, “Hello there!” Otherwise, null.

Lastly, we’ll make a button. First, pass the textDisappear function into the onClick. Then we can make the button say something like, “Click for a message!”

That’s it! Try it out, and don’t get discouraged.

Brad Farberman
Brad Farberman

Written by Brad Farberman

Brad Farberman is a musician and web developer based in Brooklyn, NY.

No responses yet