There is an array of this.props.bets , when trying to calculate the coefficient jumps 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. 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. :

 render() { let odd = 1; this.props.bets.map((bet) => { odd *= bet.odd; }); this.setState({ odds: odd }); return (...) } 

    1 answer 1

    Well, it turns out that you call setState in rendere. and setState leads to a render. That run on the cycle

    Use for example componentWillMount. Well, in general, you can directly solve this in the constructor

     constructor(props) { super(props) const {bets} = this.props; let odd = 1; bets.map((bet) => { odd *= bet.odd; }); this.state = { odds: odd } } 
    • It does not quite fit, because new elements will be added to this.props.bets - Alexey Presman
    • Although I found a way out: I need to use componentWillReceiveProps . but thanks for showing me where to dig :) - Alexey Presman