"classCallCheck" error by react-redux

Hi Coders!

I’m getting

Uncaught TypeError: Cannot call a class as a function
at classCallCheck (react-redux.js:892)

I checked out that line of code from react-redux.js, but didn’t understand it:

var classCallCheck = function (instance, Constructor) {
  if (!(instance instanceof Constructor)) {
    throw new TypeError("Cannot call a class as a function");
  }
};

I spent a while googling this with searches like [“classCallCheck” redux] and [“at classCallCheck”], but only found issues that seemed more complex than my code.

One person said it happened because they forgot to write extends React.Component but I triple checked to make sure I wrote that in the right places.

Any suggestions for where else I can look for answers about this? Or if you have a moment to look at my codepen, that would be so helpful! :innocent:

Thanks!
-jan

Your problem is here:

const ConnectedComponent = connect(mapStateToProps)(mapDispatchToProps)(
Presentational
);

The correct syntax is:
const ConnectedComponent = connect(mapStateToProps, mapDispatchToProps)( Presentational );

I think it was like you were using mapStateToProps and MapDispatchToProps as function and not as arguments of connect() function^^

1 Like

Wow! That’s such a relief. Thank you so much @Layer …I checked the code so many times and didn’t find that. You’re amazing! :smile:

1 Like