reactjs - 如何在 Mozilla 控制台上查看我的快照?
问题描述
所以我是 React 的新手,并通过基于项目的课程学习它。我被困住了,希望你们好人会有所帮助。
因此,我将本地数据添加到 firestore,以便稍后将其取回我的应用程序并将其添加到我的 reducer,以便更轻松地从不同设备访问数据。我遇到的问题是显示我的文档快照。现在从教程中,他显示了他的文档快照,但从我的角度来看,我从日志中什么也得不到。
将我的数据添加到 firestore(在我创建的 firestore 文件中)的代码是:
export const addCollectionAndDocuments = async (
collectionKey,
objectsToAdd
) => {
const collectionRef = firestore.collection(collectionKey);
const batch = firestore.batch();
objectsToAdd.forEach((obj) => {
const newDocRef = collectionRef.doc();
batch.set(newDocRef, obj);
});
return await batch.commit();
};
显示我的快照的代码(在我导入我的 firestore 文件的不同文件中)是:
class ShopPage extends React.Component {
unsubscribeFromSnapshot = null;
componentDidMount() {
const collectionRef = firestore.collection('collections');
collectionRef.onSnapshot(async (snapshot) => {
console.log(snapshot);
});
}
render() {
const { match } = this.props;
return (
<div className="shop-page">
<Route exact path={`${match.path}`} component={CollectionOverview} />
<Route path={`${match.path}/:collectionId`} component={CollectionPage} />
</div>
);
}
预期输出:我从 firestore 获得的查询快照,即(一个包含 5 个查询文档快照的数组)。【预期输出截图】:https ://i.stack.imgur.com/UdDNM.jpg
当前输出:我的快照没有日志。
请帮助!
解决方案
我将浏览器从 Mozilla Firefox 更改为 Chrome,一切正常。我在 chrome 控制台中记录了我的快照查询。
推荐阅读
- ruby-on-rails - Rails Net::SFTP 连接超时
- wav - sox 生成的 wav 标头不正确
- r - 与序数预测器一起使用的最佳方法是什么?
- c# - 重新加载 Windows 窗体变量而不重新加载表单布局
- vb.net - 最近几点了?
- json - BackBlazeTokenResponse - com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:无法识别的字段“允许”
- java - 将 SpringCloud Finchley 升级到 RELEASE 时缺少 AmazonS3Client Bean
- c# - 模板在 C# 的内容控制中不起作用
- javascript - 包括节点模块以加载本地 CSV 文件并运行 wink-naive-bayes-text-classifier
- json - 如何在 protobuf 或 grpc 中使用 json 作为结构成员?