Fix StatusList memoization

This commit is contained in:
Alex Gleason 2021-07-01 19:41:16 -05:00
parent 8961fc1b68
commit 352c87c3b7
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 15 additions and 10 deletions

View File

@ -21,9 +21,11 @@ const makeGetStatusIds = () => createSelector([
}); });
}); });
const makeMapStateToProps = () => {
const getStatusIds = makeGetStatusIds();
const mapStateToProps = (state, { timelineId }) => { const mapStateToProps = (state, { timelineId }) => {
const lastStatusId = state.getIn(['timelines', timelineId, 'items'], ImmutableList()).last(); const lastStatusId = state.getIn(['timelines', timelineId, 'items'], ImmutableList()).last();
const getStatusIds = makeGetStatusIds();
return { return {
statusIds: getStatusIds(state, { type: timelineId }), statusIds: getStatusIds(state, { type: timelineId }),
@ -35,6 +37,9 @@ const mapStateToProps = (state, { timelineId }) => {
}; };
}; };
return mapStateToProps;
};
const mapDispatchToProps = (dispatch, ownProps) => ({ const mapDispatchToProps = (dispatch, ownProps) => ({
onDequeueTimeline(timelineId) { onDequeueTimeline(timelineId) {
dispatch(dequeueTimeline(timelineId, ownProps.onLoadMore)); dispatch(dequeueTimeline(timelineId, ownProps.onLoadMore));
@ -47,4 +52,4 @@ const mapDispatchToProps = (dispatch, ownProps) => ({
}, 100), }, 100),
}); });
export default connect(mapStateToProps, mapDispatchToProps)(StatusList); export default connect(makeMapStateToProps, mapDispatchToProps)(StatusList);