score:3

Accepted answer

this would certainly work:

axischange(event) {
    event.persist();
    this.setstate(prevstate => ({
        selectedtemplatedata: {
            ...prevstate.selectedtemplatedata,
            axislables: [...event.target.value.split(',')]
        }
    }))
}

if there is no comma, the value will be preserved. if there is a comma, you can split the values and spread them into the new array.

score:1

here you'll find other examples, but a simple way to do it is the following:

axischange(event) {
    event.persist();
    const e = event && event.target && event.target.value;
    const values = e && e.split(',').length > 1
      ? e.split(',')
      : e;
    this.setstate(prevstate => ({
        selectedtemplatedata: {
            ...prevstate.selectedtemplatedata,
            axislables: [ values[0], values[1], values[n] ]
        }
    }))
}

Related Query

More Query from same tag