0

I am trying to reload a button once it is clicked so that it will give more numbers.

<button onClick={console.log(0)}>zero</button>
<button onClick={console.log(1)}>one</button>

When I click it once it just gives me the number once in the console log. How do you get it to give me more than one number?

AltBrian
  • 2,392
  • 9
  • 29
  • 58
  • 1
    What do you mean "give me more than one number"? Do you want the console.log function to change each time the button is clicked, or a new element to appear on the screen, or the text of the button should change? – Blundering Philosopher Jul 01 '18 at 11:30
  • I was wondering that each time the button is clicked it would give me the same number in the console log. Not sure if it is possible or am I going about this the wrong way? – AltBrian Jul 01 '18 at 11:34
  • aah that makes sense - check Tobias's answer below – Blundering Philosopher Jul 01 '18 at 11:36

1 Answers1

1

You should give a function to onClick, not the result of a single console.log().

Try:

<button onClick={() => console.log(0)}>zero</button>
<button onClick={() => console.log(1)}>one</button>
Tobias K.
  • 2,997
  • 2
  • 12
  • 29