ReactJS mounting have 3 methods:
- getInitialState(): object is invoked before a component is mounted. Stateful components should implement this and return the initial state data.
- componentWillMount(): is invoked immediately before mounting occurs.
- componentDidMount(): is invoked immediately after mounting occurs. Initialization that requires DOM nodes should go here.
In Button component getInitialState() method initial val: 0 by default.
When you click on Mount button, componentWillMount() method is invoked immediately before mounting occurs, and render() method render button into body DOM, and then componentDidMount() method is invoked immediately after mounting occurs.