reactjs - 如何在 React 组件中等待 Redux 状态更新?
问题描述
我有以下动作创建者,我需要在 React 组件中等待。它需要运行完成(在reducer 更新存储之后),因为React 组件需要访问它。如何在我的 React 组件中使用以下内容?这是实验性 Suspense API 将提供的吗?
await updateLocation()
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
(res) => {
if (res) {
reverseGeoCodeCoords(res)
.then((d) => {
dispatch({
type: UPDATE_USER_LOCATION,
payload,
});
}
}
}
})
.catch((err) => {
console.log(err);
});
}
},
(err) => {
}
);
} else {
console.log("Browser doesn't support geolocation.");
}
};```
解决方案
推荐阅读
- jpeg - 在 Android Camera2 API 中。我可以使用图像读取器 (YUV_420_888) 进行处理,使用另一个 (JPEG) 来捕获静止图像吗?
- javascript - Express 路由提供 500 个内部服务器
- c# - 列表不断重置为空。我怎样才能解决这个问题?
- excel - VBA 中 workbooks.open 的奇怪问题
- python - 如何使用不会导致 PEP 警告的选项卡
- c++ - 用于读写的 OpenCL OpenGL 互操作内核参数
- mysql - 如何将 SQL 查询转换为 Laravel 格式
- c++ - 单独的 QThread 中的串行端口
- php - 是否可以在两个 varchar 值之间执行
- r - 13:30:00 和 13:32:00 之间的子集数据在 mac 上有效,但在 windows 上无效,为什么?