【发布时间】:2018-08-23 20:02:27
【问题描述】:
有没有人用过这个很棒的反应组件来处理服务器端数据?
如果您不需要手动更新数据,here 给出的解决方案非常好。
我不仅需要在更改 page/pageSize/sorting/filtering 时刷新数据,还需要在一段时间后刷新数据,以查看数据是否已更改。
我还有一个表格扩展,允许用户对所有列进行全文搜索,因此当用户更改自定义搜索框的内容时,我也需要更新数据。
【问题讨论】:
标签: reactjs react-table
有没有人用过这个很棒的反应组件来处理服务器端数据?
如果您不需要手动更新数据,here 给出的解决方案非常好。
我不仅需要在更改 page/pageSize/sorting/filtering 时刷新数据,还需要在一段时间后刷新数据,以查看数据是否已更改。
我还有一个表格扩展,允许用户对所有列进行全文搜索,因此当用户更改自定义搜索框的内容时,我也需要更新数据。
【问题讨论】:
标签: reactjs react-table
我遇到了和你一样的问题,我开始寻找 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();
});
有关详细信息,请参阅this medium article。
【讨论】: