Replies: 2 comments 3 replies
-
|
Beta Was this translation helpful? Give feedback.
-
|
@snnsnn, I'm not comparing const updateNames = () => {
console.log("Button Clicked");
batch(() => {
setFirstName(firstName() + "n");
setLastName(lastName() + "!");
})
}we'd do something along these lines: const updateNames = batchCallback(() => {
console.log("Button Clicked");
setFirstName(firstName() + "n");
setLastName(lastName() + "!");
})It's just a small change to write less code. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
It would be nice to have a
batchCallbackversion of thebatchfunction that wraps a callback directly (the same way React providesuseCallbackeven though you could achieve the same thing withuseMemo). The reason behind that is it seems thatbatchis mostly used with callback functions similar to how it's explained in the tutorials. So my proposal is to add something like this:Beta Was this translation helpful? Give feedback.
All reactions