Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.
I have made a component in react JS which is returning the color name. I just want to store that color name in my parent component , so how can I do this ?
here is my code line which is creating error :
{this.setState({navColor: <ChangeNavColor stage={this.state.Stage}/>})}
or is there any another way that I can store this component return value in a variable and that variable I will assign to this "navColor" state ?
you need to call function :
{()=>this.setState({navColor: <ChangeNavColor stage={this.state.Stage}/>})}