-
Notifications
You must be signed in to change notification settings - Fork 48.8k
Document ReactDOM.unstable_batchedUpdates #5880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
We generally don't document the Also, FWIW, this function is really only useful to react framework authors (ie. not the general public component authors), so top-level api docs are probably too prominent. Most of the framework authors are tied into github and know how to find the unstable/undocumented functionality. |
Can I get a second opinion on this? @spicyj ? We saw an over 25% speedup in a part of Instagram.com after using this hook, so I disagree with the notion that it's only useful to framework authors. This should be accessible to everyone to eke out perf wins. |
25% faster on what sort of operation? |
We used this for batching Flux |
I don't feel strongly either way about documenting it so I am willing to follow @jimfb's lead in saying no. We do want to move to automatically batching everything, at which time this hook is moot. Until then it will probably stay where it is. |
On rerendering when you navigate to a new post. This is easy to document (I've already done it), will enable people to write more performant apps and ship better UX, and is easily codemodded away if and when automatic batching comes to pass (which is probably at least months away from being in a release, yes?). Why not? |
This doesn't help me to understand. Specifically, what operations is the app doing that results in a benefit from batching (and why is the app doing whatever operations it is doing). A single rerender would not benefit from batching.
It is not about how easy/hard it is to document - it's about the stability guarantees we're making. If we want to release this as stable, we could consider that, but we shouldn't document something that is |
@jimfb, N>1 Flux stores emit change events. Naively, this leads to N renders. You skipped over my key point as to why the benefits of documenting outweigh the downsides:
|
@graue I'd be interested in a code snippet how you did that. |
class MyDispatcher extends Dispatcher {
constructor() {
super();
this._actuallyDispatch = Dispatcher.prototype.dispatch.bind(this);
}
dispatch(payload) {
ReactDOM.unstable_batchedUpdates(this._actuallyDispatch, payload);
}
}
export default new MyDispatcher(); This is from memory, may not be 100% right. |
@sophiebits did you finally move to automatically batching everything? |
Not yet. |
Took a stab at documenting this. Let me know what you think.
Fixes #3570