Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/380.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript rsuite表在状态数据更改时不更新_Javascript_Reactjs_Rsuite - Fatal编程技术网

Javascript rsuite表在状态数据更改时不更新

Javascript rsuite表在状态数据更改时不更新,javascript,reactjs,rsuite,Javascript,Reactjs,Rsuite,这是我的渲染方法 render() { return ( <Contentbox> <ol> {this.state.data.map((obj) => ( <li key={obj._id}>{obj.name}</li> ))} </ol>

这是我的渲染方法

render() {
    return (
        <Contentbox>
            <ol>
                {this.state.data.map((obj) => (
                    <li key={obj._id}>{obj.name}</li>
                ))}
            </ol>
            <Table
                height={420}
                autoHeight
                affixHeader
                data={this.state.data}
                sortColumn={this.state.sortColumn}
                sortType={this.state.sortType}
                onSortColumn={this.handleSortColumn}
                loading={this.state.loading}
                onRowClick={data => {
                    console.log(data);
                }}
            >
                <Column width={70} align="center" fixed sortable>
                    <HeaderCell>Id</HeaderCell>
                    <Cell dataKey="sid" />
                </Column>

                <Column width={200} sortable resizable>
                    <HeaderCell>Name</HeaderCell>
                    <Cell dataKey="name" />
                </Column>

                <Column width={150} sortable resizable>
                    <HeaderCell>(Rs) Value</HeaderCell>
                    <Cell dataKey="value" />
                </Column>

                <Column width={150} sortable>
                    <HeaderCell>Status</HeaderCell>
                    <Cell dataKey="gender" />
                </Column>

                <Column width={80} fixed="right">
                    <HeaderCell>Action</HeaderCell>
                    <ActionCell dataKey={'id'} updateDataTable={this.updateData} />
                </Column>
            </Table>
        </Contentbox>
    );
}
状态已正确更新,但表未更新。我正在使用rsuite表。

const updatedRow=obj;
updatedRow.sid=formValue.id
updatedRow.name=formValue.name
updatedRow.value=formValue.value
updatedRow.gender=formValue.gender
newDataArr.push(updatedRow)
尝试将上述代码修改为:

newDataArr.push({
…obj,
sid:formValue.id,
名称:formValue.name,
value:formValue.value,
性别:formValue.gender
});
updateData = (rowData, formValue) => {
    let newDataArr = [];
    console.log('do something: ' + rowData._id + " form value: " + formValue.id);
    this.state.data.forEach(function (obj) {
        if (obj._id !== rowData._id) {
            newDataArr.push(obj);
        } else {
            const updatedRow = obj;
            updatedRow.sid = formValue.id
            updatedRow.name = formValue.name
            updatedRow.value = formValue.value
            updatedRow.gender = formValue.gender
            newDataArr.push(updatedRow)
        }
    });
    console.log('new data array ' + JSON.stringify(newDataArr));
    this.setState({
        ...this.state,
        data: newDataArr
    });
}