Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>On each key event you have to update the screen so that appears to scroll up. But React gets in the way by batching setStates

This does not sound correct. Quoting directly from the page on automated batching (https://github.com/reactwg/react-18/discussions/21):

>Note: React only batches updates when it’s generally safe to do. For example, React ensures that for each user-initiated event like a click or a keypress, the DOM is fully updated before the next event. This ensures, for example, that a form that disables on submit can’t be submitted twice.

If you see a problem like the one you're describing, please file an issue in the main React repo, and we'll have a look. I'm not sure how you could have experienced this behavior since we released the alpha an hour ago.



To clarify, I am not talking about the React 18 feature. I have this problem in React 17. On Pagedown key, I throttle the setState calls because calling it too fast causes React to batch the updates. I'll try to make an standalone repro and open an issue in the React repo.


Automatic batching is new in 18 so I suspect something else is up. A repro case would be highly appreciated! Thanks.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: