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.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Brad Farberman
Brad Farberman

Written by Brad Farberman

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

No responses yet

Write a response