admin管理员组文章数量:1428984
This is my code:
My container:
import {connect} from 'react-redux';
import UI from '../../ui/studentRegistrationUI/RegisterFormUI'
import {beginRegistration, setLevel} from "../../../../actions";
const mapStateToProps = state => ({user: state.user});
const mapDispatchToProps = dispatch => ({
handleClick() {
dispatch(beginRegistration('student'));
}
});
export default connect(mapStateToProps, mapDispatchToProps)(UI)
My UI ponent:
//imports
export default (handleClick = f => f) => (
<div className="table_bg">
<div className="container">
<div className="row">
<Button className='custom_register_button'
onClick={handleClick}>
</Button>
</div>
</div>
</div>
);
Right now I am trying to create a dispatcher and send it to the UI to be called when a button is clicked. I am still new to Redux. The problem is, I am getting this error, whenever I try to launch the app:
Failed prop type: Invalid prop
onClick
of typeobject
supplied toButton
, expectedfunction
.
What am I missing?
This is my code:
My container:
import {connect} from 'react-redux';
import UI from '../../ui/studentRegistrationUI/RegisterFormUI'
import {beginRegistration, setLevel} from "../../../../actions";
const mapStateToProps = state => ({user: state.user});
const mapDispatchToProps = dispatch => ({
handleClick() {
dispatch(beginRegistration('student'));
}
});
export default connect(mapStateToProps, mapDispatchToProps)(UI)
My UI ponent:
//imports
export default (handleClick = f => f) => (
<div className="table_bg">
<div className="container">
<div className="row">
<Button className='custom_register_button'
onClick={handleClick}>
</Button>
</div>
</div>
</div>
);
Right now I am trying to create a dispatcher and send it to the UI to be called when a button is clicked. I am still new to Redux. The problem is, I am getting this error, whenever I try to launch the app:
Failed prop type: Invalid prop
onClick
of typeobject
supplied toButton
, expectedfunction
.
What am I missing?
Share Improve this question asked Jan 2, 2019 at 12:42 Alex IronsideAlex Ironside 5,07914 gold badges76 silver badges135 bronze badges1 Answer
Reset to default 4Fixed it by destructing like so:
export default ({handleClick = f => f}) => (
本文标签:
版权声明:本文标题:javascript - Failed prop type: Invalid prop `onClick` of type `object` supplied to `Button`, expected `function` - Stack Overflo 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745444856a2658616.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论