I'm really struggle to understand where this code goes wrong. I can't concat two times in a row because it turns my array into an object. Here is the code...
this.setState((prevState) => ({
      //Add new bet to users array of bets
      usersByName: {
        ...prevState.usersByName,
        [newBet[0].name]: {
          ...prevState.usersByName[newBet[0].name].concat(newBet),
          amountleft: prevState.usersByName[newBet[0].name].amountleft - newBet[0].amount,
          lastweekroi: prevState.usersByName[newBet[0].name].lastweekroi,
          thisweekroi: prevState.usersByName[newBet[0].name].thisweekroi,
        },
      },
    }))
The initial structure is correct and looks like this.
When I run the setstate command it changes the structure to this, which I can't then run concat again because I get the error .concat is not a function
Does anyone see a way to fix this? Arrays, JSON and this stuff is confusing. Thanks


