简体   繁体   English

ReactJS您必须将组件传递给connect返回的函数

[英]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.

相关问题 您必须将一个组件传递给 connect 返回的函数。 而是收到未定义 - You must pass a component to the function returned by connect. Instead received undefined 如何修复错误:“您必须将组件传递给连接返回的 function。 而是在我的 React-Redux 应用程序中收到 {}”? - How to fixed error: “You must pass a component to the function returned by connect. Instead received {}”, in my React-Redux app? '必须返回一个有效的React元素(或null)'与ReactJS中的一个组件一起出错 - 'A valid React element (or null) must be returned' error with one of the component in ReactJS 道具Griddle自定义组件中的传递函数-ReactJS - Pass function in props Griddle custom component - ReactJS 将函数参数传递给另一个组件reactjs - pass function argument to another component reactjs 如何将实例传递给 reactjs 中组件内的 function - How to pass an instance to a function within a component in reactjs 将 function 作为 prop 传递,然后使用功能组件将其作为参数传递给 ReactJs 中的 function - Pass function as prop and then pass it as argument to function in ReactJs using functional component ReactJs - 输入组件从 function 返回时表现异常 - ReactJs - Input Component behaves strangely when its returned from a function 当我将 function 传递给子组件时,ReactJS this.props.* 不是 function - ReactJS this.props.* is not a function when I pass a function to child component 在 reactjs 中将组件作为道具传递 - pass component as prop in reactjs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM