0
votes

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 component:

//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 type object supplied to Button, expected function.

What am I missing?

1

1 Answers

3
votes

Fixed it by destructing like so:

export default ({handleClick = f => f}) => (