reactjs - Firestore在React Application中通过Redux-Saga添加数据时添加重复记录
问题描述
我正在尝试在反应应用程序中使用 redux-saga 在 Firestore 中添加记录。我可以添加数据,但它会添加两次相同的数据。但是在页面刷新时,重复数据会自动删除。你能看看下面的方法为什么会这样吗?
export function* onAddContactAsync({ payload: contact }) {
try {
yield delay(500)
yield new Promise((resolve) => {
db.collection("contacts").doc().set(contact, resolve);
});
yield put(addContactSuccess());
} catch (error) {
yield put(addContactFail());
}
}
export function* onAddContact() {
yield takeLatest(types.ADD_CONTACT_START, onAddContactAsync);
}
const combineSagas = [fork(onAddContact)];
export function* contactsSagas() {
yield all([...combineSagas]);
}
解决方案
推荐阅读
- sql-server - 查找范围内数字的位置
- asp.net-mvc - Elmah - 不要记录完整的堆栈跟踪
- python - 如何使用测试客户端填写 Django 表单
- php - 使用 PHP 进行试除素因式分解
- java - 尝试打开谷歌地图时应用程序已停止
- python - 如何在 Python 3.6 中读取文件并分离其内容
- angularjs - 删除在 AngularJS 中动态创建的局部视图
- java - Java 9 中的 JAXB 模块问题
- javascript - 使用 jquery/css 隐藏元素
- elasticsearch - Elasticsearch 内存使用率随着时间的推移而增加并达到 100%