Answer the question
In order to leave comments, you need to log in
Why is reselect not working?
selector
import { createSelector } from 'reselect';
const getGames = state => state.game.games;
export const gamesSelector = createSelector(getGames, games => games);
import { gamesSelector } from '../../../selectors';
const mapStateToProps = state => ({
games: gamesSelector(state),
});
Answer the question
In order to leave comments, you need to log in
What did you expect? You're creating a useless selector that doesn't select anything, but simply passes the games object through. Then, you pass this object in its entirety to connect. Naturally, when it changes, your component will re-render all child components in a chain.
Do a shouldComponentUpdate check in the Game components and compare the incoming objects:
shouldComponentUpdate(nextProps) {
return nextProps.game !== this.props.game;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question