[英]ReactJS You must pass a component to the function returned by connect
You must pass a component to the function returned by connect. 您必须将组件传递给connect返回的函数。 Instead received {"id":"-LGZkSJah62kXrfUl-6u","teamA":"England","teamB":"England"}
而是收到{“ id”:“-LGZkSJah62kXrfUl-6u”,“ teamA”:“英格兰”,“ teamB”:“英格兰”}
So the function returned by connect is 'initAddMatchResult'. 因此,connect返回的函数为“ initAddMatchResult”。 Why is it not approprite to pass the team variables?
为什么不适当传递团队变量?
Hi, I am creating a React application with redux and getting the error ..You must pass a component to the function returned by connect. 嗨,我正在用redux创建一个React应用程序,并收到错误消息..您必须将一个组件传递给connect返回的函数。 Instead received {"id":"-LGZkSJah62kXrfUl-6u","teamA":"England","teamB":"England"}
而是收到{“ id”:“-LGZkSJah62kXrfUl-6u”,“ teamA”:“英格兰”,“ teamB”:“英格兰”}
I have a function on my component which correctly calls 我的组件上有一个可以正确调用的函数
addMatchResultHandler = (id, teamAName, teamBName) => {
this.setState({
inputtingResult: true
})
this.props.onAddMatchResult( id, teamAName, teamBName);
}
the action to dispatch .. 派遣行动..
const mapDispatchToProps = dispatch => {
return {
onFetchUpcomingMatches: () => dispatch(actions.fetchUpcomingMatches()),
onAddMatchResult: (matchID, teamAName, teamBName ) => dispatch(actions.initAddMatchResult(matchID, teamAName, teamBName))
}
}
export const initAddMatchResult = ( matchID, teamAName, teamBName ) => {
return {
type: actionTypes.INIT_MATCH_RESULT_INPUT,
matchId: matchID,
teamAName: teamAName,
teamBName: teamBName
};
}
which correctly updates the state in the reducer. 正确更新减速器中的状态。
const initAddMatchResult = ( state, action ) => {
return updateObject( state, {
selectedMatchForUpd: {
matchID: action.matchId,
teamAName: action.teamAName,
teamBName: action.teamBName
}
} );
}
I have confirmed in redux that selectedMatchForUpd is getting updated with the correct values. 我已经在redux中确认,selectedMatchForUpd正在使用正确的值进行更新。 So why is this error being thrown?
那么为什么会引发此错误呢? any help would be much appreciated.
任何帮助将非常感激。
Arghh I wasn't .... 啊,我不是....
I had export default connect(mapStateToProps, mapDispatchToProps(MatchResultInput)); 我已经导出了默认的connect(mapStateToProps,mapDispatchToProps(MatchResultInput));
I should have sorted that one myself. 我本应该对那个人进行排序。 Thanks.
谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.