При получении данных из API и обновлении хранилища реквизиты моего компонента не обновляются. Он работает правильно при вызове метода getGames, но не метода getGame.
Я знаю, что действие / редуктор работает, так как этот метод работает в других компонентах. Кроме того, я знаю, что вызывается действие (инструменты редукционного разработчика).
Компонент:
class Dashboard extends Component {
static propTypes = {
games: PropTypes.array.isRequired,
game: PropTypes.object,
getGames: PropTypes.func.isRequired,
getGame: PropTypes.func.isRequired,
};
constructor(props) {
super(props);
this.openGamePanel = this.openGamePanel.bind(this);
this.state = {
rightPanelOpen: false,
gameid: null,
};
}
componentDidMount() {
this.props.getGames();
}
openGamePanel(game) {
this.props.getGame(game.id);
this.setState({
gameid: game.id,
});
}
check() {
console.log(this.props);
}
toggleRightPanel() {
this.setState({
rightPanelOpen: !this.state.rightPanelOpen,
});
}
render() {
return (
<Fragment>
<Map games={this.props.games} />
<UIPanelLeft
games={this.props.games}
check={() => this.check()}
handleOpenGamePanel={this.openGamePanel}
/>
{this.props.game ? (
<GamePanel game={this.props.game} key={this.props.game.id} />
) : (
<div></div>
)}
</Fragment>
);
}
}
const mapStateToProps = (state) => ({
games: state.games.games,
game: state.game,
location: state.location,
});
export default connect(mapStateToProps, { getGames, getGame })(Dashboard);