Skip to content

Commit 0887834

Browse files
committed
Use appropriate batched update API for subscriptions
1 parent 266ca97 commit 0887834

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/utils/Subscription.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { unstable_batchedUpdates } from 'react-dom'
1+
import { getBatch } from './batch'
22

33
// encapsulates the subscription logic for connecting a component to the redux store, as
44
// well as nesting subscriptions of descendant components, so that we can ensure the
@@ -7,7 +7,7 @@ import { unstable_batchedUpdates } from 'react-dom'
77
const CLEARED = null
88
const nullListeners = { notify() {} }
99

10-
function createListenerCollection() {
10+
function createListenerCollection(batch) {
1111
// the current/next pattern is copied from redux's createStore code.
1212
// TODO: refactor+expose that code to be reusable here?
1313
let current = []
@@ -21,7 +21,7 @@ function createListenerCollection() {
2121

2222
notify() {
2323
const listeners = (current = next)
24-
unstable_batchedUpdates(() => {
24+
batch(() => {
2525
for (let i = 0; i < listeners.length; i++) {
2626
listeners[i]()
2727
}
@@ -83,7 +83,7 @@ export default class Subscription {
8383
? this.parentSub.addNestedSub(this.handleChangeWrapper)
8484
: this.store.subscribe(this.handleChangeWrapper)
8585

86-
this.listeners = createListenerCollection()
86+
this.listeners = createListenerCollection(getBatch())
8787
}
8888
}
8989

0 commit comments

Comments
 (0)