How to add a new key value to react js state array?

前端 未结 2 1489
逝去的感伤
逝去的感伤 2021-01-03 03:49

I want to add new key value to array ınto state? I tell you what I want to do below. How can I do that? 1. Start state in consruture method

`this.state = {
          


        
2条回答
  •  醉话见心
    2021-01-03 04:38

    I think This will meet the above scenario.

    const newFile = this.state.files.map((file) => {
    
        return {...file, key4: val4};
    });
    this.setState({files: newFile });
    

提交回复
热议问题