我有一个删除按钮,可以从firestore中删除文档,它工作良好,它在我的适配器类上,因为我创建的按钮位于适配器正在使用的布局中。 我需要回收视图在删除文档后自行刷新,我已经添加了// updateList //方法来更新回收器,但是当我单击删除时,阵列列表中的所有项目都将被删除,我需要按回去在手机上重新布局,并在那里找到除删除的文件以外的文件。 我的意思是删除(清除)列表后没有重新加载。
请检查以下代码:
class AnotherItem extends Component {
constructor() {
super();
this.state = {
itemX: ''
};
}
static getDerivedStateFromProps(nextProps, prevState) {
if(nextProps.loadItemId !== prevState.loadItemId) {
return { itemX: nextProps.loadItemId }
}
render () {
console.log(this.state.itemX ? this.state.itemX['completed'] : '');
{/*if this.state.loadX['completed'] === true, call function this.start()*/ }
return (
<button /*{this.state.loadX['completed'] ? this.start() : ''}*/ onClick={this.start}>
Start
</button>
);
}
}