Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit a2f2070

Browse files
committed
Put setSate in the promise constructor
Avoids local variables. Also typo in comment.
1 parent 225fe67 commit a2f2070

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/components/structures/TimelinePanel.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -345,19 +345,15 @@ var TimelinePanel = React.createClass({
345345
}
346346

347347
// Don't resolve until the setState has completed: we need to let
348-
// the component update before we consider the pagination commpleted,
348+
// the component update before we consider the pagination completed,
349349
// otherwise we'll end up paginating in all the history the js-sdk
350350
// has in memory because we never gave the component a chance to scroll
351351
// itself into the right place
352-
let resolveSetStatePromise;
353-
const setStatePromise = new Promise(function(resolve) {
354-
resolveSetStatePromise = resolve;
355-
});
356-
this.setState(newState, () => {
357-
resolveSetStatePromise(r);
352+
return new Promise((resolve) => {
353+
this.setState(newState, () => {
354+
resolve(r);
355+
});
358356
});
359-
360-
return setStatePromise;
361357
});
362358
},
363359

0 commit comments

Comments
 (0)