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
}
/>);