reactjs - ReactTable 和自定义服务器端数据更新
问题描述
有没有人用过这个很棒的反应组件来处理服务器端数据?
如果您不需要手动更新数据,这里给出的解决方案非常好。
我不仅需要在更改 page/pageSize/sorting/filtering 时刷新数据,而且还需要在一段时间后刷新数据,以查看数据是否已更改。
此外,我还有一个表格扩展,允许用户对所有列进行全文搜索,因此当用户更改自定义搜索框的内容时,我也需要更新数据。
解决方案
我遇到了和你一样的问题,我开始寻找 ReactJs 的异步测试,我发现这篇文章非常有用。关键部分是在 Enzyme 组件上使用“更新”方法,如下所示:
const items = ['die Straße', 'die Adresse', 'die Nationalität'];
jest.useFakeTimers();
describe('<DelayedList />', () => {
test('it renders the items with delay', () => {
const component = shallow(
<DelayedList items={items} />
);
jest.runAllTimers();
component.update(); // <--- force re-render of the component
expect(component.state().currentIndex).toEqual(items.length);
expect(component).toMatchSnapshot();
});
有关详细信息,请参阅这篇中型文章。
推荐阅读
- node.js - 在 nuxt 中使用 newrelic
- python - Python数组中使用的不同类型代码有什么区别?
- mongodb - mongodb,通过哈希键查找
- python - 由于 python 运行器上的语法错误,无法运行 py 文件
- c# - 检查 DateTime 是否大于另一个 DateTime 的正确方法
- ios13 - 语音工具包中的“OnDeviceRecognition”不起作用
- python - 如何使用 python 在 linux 中解析 logrotate.conf 文件
- javascript - react-native-calendar : 如何选择有限的天数
- r - rvest::html_text 和 RSelenium::getPageSource 有什么区别?
- angular - 如何从外部 URL 访问特定的 Angular 组件?