mattermost-mobile/app/utils/list_view.js
Harrison Healey db3556325e RN-566 Re-rendered PostList footer when channel ID changes (#1309)
* RN-566 Re-rendered PostList footer when channel ID changes

* Refactor ChannelIntro mapStateToProps into selectors
2017-12-22 10:29:09 -06:00

22 lines
760 B
JavaScript

// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import shallowEqual from 'shallow-equals';
// Returns a function that will construct a memoized array of its arguments for use as
// the extraData prop for a ListView so that its rows can be re-rendered even if the items
// themselves don't change.
export function makeExtraData() {
let lastArgs = [];
// Returns an array containing the arguments provided to this function.
// If this function is called twice in a row with the same arguments,
// it will return the exact same array.
return (...args) => {
if (!shallowEqual(lastArgs, args)) {
lastArgs = args;
}
return lastArgs;
};
}