Last active
December 30, 2022 08:23
-
-
Save farzadso/1909ec448e751cae5682fb540e01c685 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
updateStepFourProps(type, operation, data) { | |
let localData = []; | |
if (operation === 'add') { | |
if (type === 'educationalBackground') { | |
// Create Local Copy | |
localData = this.state.educationalBackground; | |
// Push Data In Local Copy | |
localData.push(data); | |
} else if (type === 'academicCertificates') { | |
// Create Local Copy | |
localData = this.state.academicCertificates; | |
// Push Data In Local Copy | |
localData.push(data); | |
} | |
} else if (operation === 'remove') { | |
if (type === 'educationalBackground') { | |
// Create Local Copy | |
localData = this.state.educationalBackground.filter((item) => { | |
return item.id !== data; | |
}); | |
} else if (type === 'academicCertificates') { | |
// Create Local Copy | |
localData = this.state.academicCertificates.filter((item) => { | |
return item.id !== data; | |
}); | |
} | |
} | |
// Set New State | |
this.setState({ | |
[type]: localData, | |
}, () => { | |
// Clear localData after you're done with it | |
localData = []; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment