Bursts of data, redux buffering / react rerenderin

2019-05-30 16:09发布

Here is my data flow:

1: 500+ objects come trough socket in 1-2s bursts

2: Objects are added directly to redux store

3: React table container is connected to redux store (using it as data source) and re-renders for every object.

That many re-renders pretty much kill browser.

What options do I have to buffer incoming objects(events) and send batches to reducer every, say 1s? Even better solution would be to somehow time-limit react rendering (shouldComponentUpdate...), but I doubt it's possible?

标签: reactjs redux
3条回答
ゆ 、 Hurt°
2楼-- · 2019-05-30 16:40

I would advise looking into RxJS and redux-observable specifically. What you're looking for is debounce operator if I'm not mistaken.

RxJS has a pretty steep learning curve, but I have managed to set up a basic working solution pretty quickly.

I have been inspired by this talk and I encourage you to take a listen.

查看更多
别忘想泡老子
3楼-- · 2019-05-30 16:46

You could use a temporary cache in the reducer as local data. Maybe with a timeout before adding the data to the store object.

查看更多
混吃等死
4楼-- · 2019-05-30 16:55

You can implement your own throttle behavior using setTimeout in shouldComponentUpdate or use something ready like https://github.com/ryo33/react-throttle-render

查看更多
登录 后发表回答