score:3

Accepted answer

create a variable containing the initial state, then use it to replace the current state when you want to clear, like the below example:

 const initstate = {
  text: '0',
  array: [],
  operators:['+']
}

...

  constructor(props) {
    super(props);
    this.state = initstate;
    this.display = this.display.bind(this);
    this.clear = this.clear.bind(this);
    this.calculate = this.calculate.bind(this);
  }

...

  clear(){
    this.setstate(initstate);

  }

Related Query

More Query from same tag