question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Depending on the store/action design of an app, batching updates can be a pretty useful/important perf optimization. @yoshuawuyts what are you thoughts on the best choo-like way to handle this? Would you be interested in adding a hook that would make this possible in some app-wide way (like maybe a way to provide ‘middleware’ function through which updated states were passed before being emitted to the view-rendering)? Or would you prefer for people to handle this by simply throttling individual view functions?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
anandthakkercommented, Jul 6, 2016

@yoshuawuyts I haven’t given it an actual test drive, but from a read of the code the approach looks great to me! I have a couple of thoughts but I’ll post them as issues over in nanoraf.

1reaction
yoshuawuytscommented, Jun 24, 2016

Ooh, yeah I’ve been considering this; combined with documenting best practices on thunking views and caching routes (https://github.com/yoshuawuyts/sheet-router/issues/17) it would def be worthwhile to put an upper cap on flushing updates.

In the past for virtual-dom applications I used yoshuawuyts/virtual-raf to flush updates at 60fps; it could def be worthwhile exploring this for choo too - especially the interaction with webworker rendering would become interesting (https://github.com/maxogden/yo-yo/issues/22).

I think this should happen after the 3.0 release though; as it’s a minor tweak without practical API changes. Does this answer what you meant? Cheers!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Simplifying state management in React apps with batched ...
By default, React batches updates made in a known method like the lifecycle methods or event handlers, but doesn't do the same when...
Read more >
Automatic Batching in React 18: What You Should Know
React uses batching to group state updates within event handlers and inbuilt hooks. It prevents components from re-rendering for each state update and ......
Read more >
Understanding React.js (Part 2) - Batched Updates
React implements a batched updating mechanism to reduce the number of component renders. Consequently, multiple state changes will be ...
Read more >
React state batch updating - reduce re-renders - Medium
React mechanism of state batch updates. Instead of one by one, React does batch updates, reducing the number of hooks and class component ......
Read more >
React 18 adds automatic batching - Saeloun Blog
Batching is a React feature that combines all the state updates into a single update, causing a single re-render thereby improving the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found