Large amount of redux updates

(Jayson Bailey) #1

I’ve got an electron app I’m using React/Redux. The app is going to upload small files to a site, perhaps up to 10k of them. I’m listing the files and for each one, I send a NEW_FILE action, and later a UPDATE_FILE_STATUS action. These uploads happen pretty fast and it seems like react cant keep up with the constant updates.

Does anyone know of a good pattern or solution to something like this? I’m still relatively new.


(Sophie Alpert) #2

If you have thousands of updates, it’s likely that you’re causing React to rerender and update the screen thousands of times. This probably isn’t what you want. If they all come at the same time, you might want to wrap ReactDOM.unstable_batchedUpdates() around the entire update block which should batch them into a single rerender. Another option is adding throttling somewhere – perhaps where you listen to the store, you can instead throttle those updates so that the React component rerenders at most (say) once per 100ms.

(Jayson Bailey) #3

Hello, and thanks for the advice. I started to throttle my uploads and that has fixed it. I’ll take a look at just throttling the render as I do want the uploads to go as fast as they can.


(Simone Poggi) #4

Hey I had a similar problem, and I throttled my react updates aswell, care to share your code?

That’s how I did it: