我想弄清楚如何在数据中分页时在继电器现代应用程序中显示负载指示器。我有一个基于PaginationContainer的组件,并且我希望在调用其他数据(调用loadMore())时显示一个加载指示符。除了以某种方式提供一个自定义网络实现,在任何网络请求期间执行此操作时,我都没有看到任何其他方式来做到这一点。思考?继电器现代:如何显示负载指示器loadMore在分页容器
2
A
回答
0
我觉得继电器配备了一个API,让你知道,如果请求被挂起,你可以有机会获得this.props.relay.isLoading()
(见docs)
class MyComponent extends React.Component {
render() {
return {
<div>
{this.props.relay.isLoading() ? <Spinner /> : null>
// ....
</div>
}
}
}
export default createPaginationContainer(
MyComponent,
...
)
0
在我看来,这是一个常见的使用情况下应在Relay API中得到明确的支持,但以下是我能想到的最好的。鼓励其他解决方案的建议。
在我的组件,它是基于一个集装箱的分页:
constructor(arg) {
super(arg);
this.state = {isLoadingMore: false}
}
componentWillReceiveProps(nextProps) {
if (this.props !== nextProps) {
this.setState({isLoadingMore:false});
}
}
// onClick handler for "More" button
handleMore() {
if (!this.props.relay.hasMore() || this.props.relay.isLoading()) {
return;
}
this.setState({isLoadingMore: true});
this.props.relay.loadMore(
...
)
}
render() {
...
const isLoadingMore = this.state.isLoadingMore;
return (isLoadingMore ? <LoadingIndicator /> : <ListOfStuffView />
}
相关问题
- 1. 如何通过过滤器参数继电器loadMore
- 2. 继电器现代:如何模拟继电器单元测试
- 3. 加载网页时显示微调器等待指示器
- 4. 如何使用spin.js显示页面加载指示器
- 5. 如何让页脚显示(显示它在网站容器?)
- 6. 安培列表加载内容时显示加载指示器
- 7. 如何显示部分容器
- 8. jQuery选项卡 - 在ajax加载期间在容器div中显示指示器
- 9. 如何指定显示器?
- 10. 显示加载程序指示器
- 11. 加载图像时显示指示器
- 12. 如何在可用内显示加载图像指示器?
- 13. 如何使指示器显示开关?
- 14. 如何显示活动指示器
- 15. 在排序或分页时显示Ajax加载指示器ASP.net MVC Webgrid
- 16. 如果儿童中继器为空,如何显示中继器的子页脚?
- 17. Android滚动页面指示器分页
- 18. 显示进度指示器
- 19. 变暗页面并显示加载指示器
- 20. 使Socket.IO显示浏览器的页面加载指示器(旋转轮)
- 21. 如何在中继器获取数据时显示“加载...”
- 22. 电子如何显示加载页面时在BrowserWindow中加载微调器
- 23. 在容器中显示UIViewController
- 24. 在双显示器上显示网页
- 25. android的电池指示器
- 26. JavaFX加载指示器显示时未显示动画
- 27. 页面加载指示器yii2
- 28. 显示容器悬停不同容器
- 29. AngularJS显示预加载器 - 指令
- 30. android水平视图分页指示器
嘿,我讨厌问,但我有继电器现代createPaginationContainer麻烦。如果你有一个时刻,可以看看:https://stackoverflow.com/questions/45126278/relay-modern-createpaginationcontainer-not-receiving-any-props – liminal18
@Vincent Taing,有趣的是,this.props.relay.isLoading ()在我调用loadMore()后在我的PaginationContainer的渲染方法中是真实的。但我的渲染方法只有一次被调用,因为我怀疑。所以我不能在这里告诉网络请求是正在进行还是已经完成。 – bjlevine