score:9

Accepted answer

players is a property on the state object, so you'll want to call setstate to update the property:

handleaddplayer = () => {
  // create a clone of your array of players; don't modify objects on the state directly
  const players = this.state.players.slice(0);

  players.push({
    name: 'maul',
    id: 26
  });

  this.setstate({
    players: players,
  });
};

Related Query

More Query from same tag