Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses and challenges
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

51
Views
Dynamic Event Handling React JS

I am using 2 different functions to do the same thing and I am trying to merge them into one, but I am unable to do so. I read such a thing can be achieved through Dynamic Event Handling. I have tried but I failed.

Below are the two functions I want to merge

 updateProfValue(index, value) {
    this.props.profValue(index, value);
  }

 updatePersonalVaue(index, value) {
    this.props.persValue(index, value);
  }

And I want them to use in this component dynamically.

{
  abc.map((item, index) => { <
    FCW
    changeHandler = {
      this.updatePersonalVaue
    }
    defaultOption = {
      item.value
    }
    index = {
      index
    }
    key = {
      item.Cn
    }
    name = {
      item.dN
    }
    required = {
      item.r
    }
    />);
  })
}

{
  xyz.map((item, index) => { <
        FCW
        changeHandler = {
          this.updateProfVaue
        }
        defaultOption = {
          item.value
        }
        index = {
          index
        }
        key = {
          item.Cn
        }
        name = {
          item.dN
        }
        required = {
          item.r
        }
        />);

7 months ago ยท Juan Pablo Isaza
Answer question
Find remote jobs