在我的应用程序中,我使用react-redux-firebase
version2.5.1
和redux-firestore
version ^0.13.0
。我呈现与客户的对话列表(称为线程),每次用户转到另一个线程时,直到它被加载,我希望他看到一个加载微调器。我的问题是,只有当我在应用程序部署后第一次进入线程时,微调器才会显示,之后每次我更改线程时,方法isLoaded
总是正确的,即使我看到页面显示了几秒钟上一个线程。有没有人遇到过这样的事情,可以帮助我如何解决它?
这是我的组件
const mapStateToProps = (state, props) => {
const customerId = props.match.params.id;
return {
thread: state.firestore.data.thread,
...
};
};
export default compose(
withStyles(styles),
connect(mapStateToProps, mapDispatchToProps),
firestoreConnect(props => [
{
collection: "thread",
doc: props.customerId,
storeAs: "thread"
}
...
])
)(ThreadView);
这是我的渲染方法
render() {
const {firebase, thread} = this.props;
const res = !isLoaded(thread); // after the first load it's always false
console.log(`customerId: ${customerId}, isLoaded: ${res}`)
if (res) {
return <LoadingSpinner/>;
}
...