Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

322
Views
React JS, how can I disable an individual button in a mapped list?

New to react, I currently have a list of buttons mapped based off an api response like so:

render() { 
  return(
      <div> 
        <h4>User Status:</h4> 
        <div className='buttonContainer'>
        {this.state.data.map((status =>   
            <li key={status.key}>
              <button id={status.key} value = {status.text} onClick={this.nextStep}/>
                {status.text}
              </button>
            </li>
          ))}
        </div>
      </div>
    )      
  }

The nextStep function changes a users status to whatever the value of the pressed button is (all based on the data) I don't want a user to be able to press a button multiple times however. How can I disable the button that was pressed without disabling every button in the list?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Just add isDisabled flag in your state data array. Like below code

[{key: 1, text: 'aa', isDisabled: true}, {key: 1, text: 'ab', isDisabled: false}]

update this isDisabled flag on Button onClick event, Based on this isDisabled flag you can disable button click.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!