在反应中设置列表时设置状态不更新

问题描述 投票:0回答:0

当我用更新的列表数据设置状态时,它没有得到更新。我的状态列表是“卡车”,仍然没有更新。我删除的数据没有反映在页面上。

adminService.requestDeleteTruck(truckId)
        .then(function (response) {
            var success = (response.errors === null || response.errors.length === 0);
            console.log(success);
            if (!success) {
                debugger
                that.setState({
                    aErrors: validationService.getErrors(response.errors, mainService.genericFormFields, that.state.aErrors)
                });
                if (that.debouncedFunction != null) that.debouncedFunction.cancel();
                that.debouncedFunction = debounce(() => {
                    that.setState({ aErrors: [] });
                }, 5000);

                that.debouncedFunction();
            }
            else {
                debugger
                var newArray = remove(that.state.trucks, (e) => {
                    return e.id != truckId
                });
                that.setState({ trucks: newArray });
            }
        });
reactjs arraylist setstate page-refresh react-state
© www.soinside.com 2019 - 2024. All rights reserved.