我正在尝试使用使用库制作的 API 并在 GraphQL 订阅的帮助下实时Apollo GraphQL
更新组件。对于删除操作,我收到错误。这是来自试图从订阅更新数据的反应组件的代码。react
subscriptions-transport-ws
TypeError: Cannot add/remove sealed array elements
componentWillReceiveProps(nextProps) {
if (!this.subscription && !nextProps.data.loading) {
let { subscribeToMore } = this.props.data
this.subscription = [subscribeToMore(
{
document: postDeleted,
updateQuery: (previousResult, { subscriptionData }) => {
const delPost = subscriptionData.data.postDeleted;
const mainData = previousResult.Posts;
let post = mainData.find(post => post.id == delPost.id);
let updatedList = mainData.splice(post, 1);
return updatedList;
},
}
)]
}
}