I want to use the value of one object to access state variable name
for ex:
const displayName = [
{
name: 'name', //Actually this is the state variable name
displayText: 'Name: '
},
{
name: 'email',
displayText: 'E-mail ID: '
}
]
{
displayName.map(obj => (
<p>{obj.displayText}</p>
<div>
{this.state.data.obj.name} //Here am facing issue. The state variables are: this.state.data.name and this.state.data.email. How to replace the obj.name here
</div>
)
}
The state variables are: this.state.data.name and this.state.data.email. How to replace the obj.name here
If i give {this.state.data.obj.name} it's throwing an error like name not found