M
M
MadBliss2020-10-30 00:50:02
React
MadBliss, 2020-10-30 00:50:02

React change image based on input value?

Help! I have some pictures that should change depending on the number entered in the input. With the useState hook, I get this value, but I don’t understand how to change imported pictures when comparing?
5f9b38dfb908b203771183.png
5f9b38872fc34237176157.png
5f9b383ecfb69306406307.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
WbICHA, 2020-10-30
@MadBliss

What vibrant colors...

const [rankLogo, setRankLogo] = useState(mmrLogo);
...
const checkMMR = () => {
  if(input >= 800) {
    setRankLogo(mmrLogo2);
  }
  ...
}

V
Vladimir, 2020-10-30
@Casufi

In src, you immediately define an image using a ternary operator
src={input > 800? logo1: logo2}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question