Reactjs 如何从本地状态弹出键为的值?

Reactjs 如何从本地状态弹出键为的值?,reactjs,Reactjs,我将本地状态作为对象: selectedDates = {}; 当我点击图标时,我会得到本地状态下的ID,即objectkey,valuepair // We "open" the value to extract the relevant informations const [key, value] = calendarIconId.split("="); // Add the new value inside of the object this.sta

我将本地状态作为对象:

selectedDates = {};
当我点击图标时,我会得到本地状态下的ID,即object
key,value
pair

    // We "open" the value to extract the relevant informations
    const [key, value] = calendarIconId.split("=");

    // Add the new value inside of the object
    this.state.selectedDatesTemp[key] = value;

    // Turn the object into an array, we gotta rebuild the values
    const date = Object.keys(this.state.selectedDatesTemp).map(
        x => `${x}=${this.state.selectedDatesTemp[x]}`
    );

如何从本地状态删除对象?

您可以使用
delete
来实现它:

const{selectedDatesTemp}=this.state;
删除所选的DatedStemp[键];

不清楚您想要实现什么。你能提供一些预期结果和当前结果的例子吗。