From 6e86d7553fa090674995ca99c4d5ad3e1a77051a Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Fri, 4 Mar 2016 13:49:15 +0000 Subject: [PATCH] Flatten arrays of components before adding to messagepanel li Avoid updating the whole DOM when we paginating by making sure the keys are right --- src/components/structures/MessagePanel.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/structures/MessagePanel.js b/src/components/structures/MessagePanel.js index 32fb2f6f77..0fe105e7ba 100644 --- a/src/components/structures/MessagePanel.js +++ b/src/components/structures/MessagePanel.js @@ -198,7 +198,10 @@ module.exports = React.createClass({ var last = (i == lastShownEventIndex); if (wantTile) { - ret.push(this._getTilesForEvent(prevEvent, mxEv, last)); + // make sure we unpack the array returned by _getTilesForEvent, + // otherwise react will auto-generate keys and we will end up + // replacing all of the DOM elements every time we paginate. + ret.push(...this._getTilesForEvent(prevEvent, mxEv, last)); prevEvent = mxEv; } else if (!mxEv.status) { // if we aren't showing the event, put in a dummy scroll token anyway, so