JavaScript React: Uncaught RangeError: Maximum call stack size exceeded react uncaught rangeerror invalid time value,rangeerror invalid time value

I'm playing around with React and I am getting the functionality I want but it is extremely slow due to an infinite loop somewhere. I believe it's in the component lifecycle methods but I'm not sure how to reformat the below code to have the same functionality but without the infinite loop. Any advice on best practices would be appreciated.

class App extends Component {
  constructor() {
    super();
    this.state = {
      num: 13,
      num2: 10,
      total: 0
    }
  }

  componentDidMount() {
    this.addNums();
  }

  componentDidUpdate() {
    this.addNums();
  }

  addNums(){
    var added = parseInt(this.state.num) + parseInt(this.state.num2);
    this.setState({total: parseInt(added)});
  }

  change(num) {
    this.setState({num: num});
    console.log(this.state);
  }
  change2(num2) {
    this.setState({num2: num2});
    console.log(this.state);
  }

  render(){
    return (
      <div>
        <TopBar />
        <Combinatoric test={this.state.num} changeNumber={this.change.bind(this)}/>
        <Combinatoric test={this.state.num2} changeNumber={this.change2.bind(this)}/>
        <h2>Total: {this.state.total}</h2>
        <h1>hello world</h1>
      </div>
    );
  }
}
Answer:1

I was looking at a solution on Codewars and I'm confused by the "=>" symbol. I thought the filter method had to take a callback function and although I can see the logic behind what's happening, I ...

I was looking at a solution on Codewars and I'm confused by the "=>" symbol. I thought the filter method had to take a callback function and although I can see the logic behind what's happening, I ...

  1. what does u003d symbol mean
  2. what does symbol mean in math
  3. what does symbol mean in literature
  4. what does symbol
  5. what does symbol mean in texting
  6. what does symbol mean in english
  7. what does symbol c mean in matric results
  8. what does symbol next to snapchat score mean
  9. what does symbol a mean in matric results
  10. what does symbol h mean in matric results
  11. what does symbol b mean in matric results
  12. what does symbol o imply in work study
  13. what does symbol mean on car insurance
  14. what does symbol x in a box mean
  15. what does symbol in math
  16. what does $ symbol mean in excel
  17. what does symbol a stand for in matric results
  18. what does symbol d imply in work study
  19. what does symbol mean in python
  20. what does symbol stand for

I want to choose (aka jQuery preselect) and set the value based on data variable. The list has 3 items having same values but differing data-d. Suppose I have variable selectvar="d" then it should ...

I want to choose (aka jQuery preselect) and set the value based on data variable. The list has 3 items having same values but differing data-d. Suppose I have variable selectvar="d" then it should ...

I'm doing a personal proyect where the user can configurate their car online. The basis is simple: 3 buttons (Change Color - Change View - Lights On/Off) and the following sprite image: As you can ...

I'm doing a personal proyect where the user can configurate their car online. The basis is simple: 3 buttons (Change Color - Change View - Lights On/Off) and the following sprite image: As you can ...

a simple question. I want to use CSS Zoom level to resize my Site oncklick. I want to catch the css zoom from "html" element. CSS html{zoom:1} JavaScript function zoomIn(){ altzoom = document....

a simple question. I want to use CSS Zoom level to resize my Site oncklick. I want to catch the css zoom from "html" element. CSS html{zoom:1} JavaScript function zoomIn(){ altzoom = document....

  1. javascript zoom level of browser
  2. javascript zoom level detect
  3. javascript get zoom level
  4. javascript set zoom level
  5. javascript change zoom level
  6. javascript window zoom level
  7. javascript get zoom level of browser
  8. javascript check zoom level
  9. javascript set zoom level of browser
  10. javascript chrome zoom level
  11. javascript reset zoom level
  12. javascript detect zoom level browser
  13. javascript determine zoom level
  14. maps javascript zoom level
  15. arcgis javascript zoom levels
  16. javascript find zoom level
  17. javascript control zoom level
  18. javascript read zoom level
  19. javascript ie zoom level
  20. esri javascript zoom levels