我在 redux 中看到了这种奇怪的连接方式,我很难理解正在做什么以及如何做。这是连接代码
export default connect(({ cricketFantasy: { matchDetails } }) => {
let innings = [];
let matchInfo = null;
let currentOver = -1;
let currentPlayer1Id = null;
if (matchDetails && Object.keys(matchDetails).length) {
const {
homeTeam,
awayTeam,
tournament,
gameDateTime,
matchDescription,
venue,
currentInning,
officials,
squad,
toss,
matchState
} = matchDetails;
if (homeTeam && homeTeam.innings && homeTeam.innings.length) {
homeTeam.innings.forEach(inning => {
innings.push({
order: inning.order,
battingTeamName: inning.battingTeam,
isCurrentInning: inning.id === currentInning.id
});
});
}
// some more operations which i deleted as that is not major concern
return {
innings,
matchInfo,
currentOver,
currentPlayer1Id,
currentPlayer2Id,
tournamentId,
squad: squadObj,
matchState: matchStateStr,
isFetchingMatchDetail: false,
routes,
detailsData: matchDetails
};
})(withStyles(styles)(withLocale(CricketScore)));
我尝试在组件的渲染方法中进行控制台登录,我看到返回的任何内容都可以视为道具。但是,我担心的是来自 ({ cricketFantasy: { matchDetails } }) 这来自。我没有看到在此代码所在的 .js 文件中的任何位置使用 cricketFantasy 一词。我也没有看到任何 mapStateToProps 。