Within my parent component I am rendering an input component looking like this
<InputField
name='source'
type='text'
input={(e) => this.inputValue(e)}
inputValue={value} />
Within my parent I need to use the name, given to this child component for a state. It should look like this
this.state = {
inputValue: {
source: "Whatever is written in the input",
text: "The value of the second input"
}
}
So within my parent I want to access the props name that I give to my child components. This way the state of the parent should dynamically uodate to the different InputFields it is rendering. My function looks like this
inputValue(e) {
this.setState({
inputValue: {
thisShouldBeTheChildsName: e.target.value
}
})
}
So how can I access the given name within this function inside of the parent?