I am trying to send data Action from my dashboard page this.props.dataActions.addChild(this.props.user.children.data[0])
.
But I have a problem with a loop. I don't know what to do in this case. Please check my code below:
I tried to add loading to componentDidUpdate
but it's not helped.
componentDidUpdate() {
//
console.log(this.state.loading)
if (this.props.user && this.props.user.children && this.props.user.children.data) {
console.log('iiiii', this.props.user.children.data[0])
this.props.dataActions.addChild(this.props.user.children.data[0])
if (!this.state.loading) {
this.setState({ selectedChildren: this.props.user.children.data[0] })
}
}
}
Please check screenshot:
What is the best way to stop the loop and send this.props.dataActions.addChild
just one time
Dashboard index code: https://pastebin.com/5V2ceAHK