Calculator Button Help

Hi all. I’m currently building the calculator project with React, and I can’t make my buttons work when I click them, except for my “delete” and “clear” keys (which have their own dedicated functions). My buttons are not child components, so that might be making things more difficult. Here’s essentially what I have right now:

The function for handling the click:

"handleStandard = (value) => (
    this.setState({
      input: this.state.input + value
    })
  );"

I’ve tried variations of the following with little success:


"<button 
            id='one'
            value='1'
            onClick={() =>this.handleStandard(this.value)}></button>"

Basically, I want to get the ‘value’ on the button to be passed as the ‘value’ argument on my handleStandard function.

I’m probably missing something somewhat simple, right? Any suggestions?

Thanks.

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums

I got it. Just manually type on the intended value of the button instead of trying to reference the value. Looks like this:

<button 
            id='one'
            value='1'
            onClick={() =>this.handleStandard('1')}></button>