Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect throws an error when connecting a memoized component #1061

Closed
Maushundb opened this issue Oct 24, 2018 · 5 comments
Closed

Connect throws an error when connecting a memoized component #1061

Maushundb opened this issue Oct 24, 2018 · 5 comments

Comments

@Maushundb
Copy link

Maushundb commented Oct 24, 2018

After upgrading my project to React 16.6.0 and migrating components to React.memo instead of Recompose.pure, connect is throwing an error when passed a memoized component:

Uncaught Error: You must pass a component to the function returned by connect. Instead received {"compare":null}

Repro:

const mapStateToProps = () => ({});
const MyComponent = React.memo(() => <div />);
const MyConnectedComponent = connect(mapStateToProps)(MyComponent);
ReactDOM.render(
  <MyConnectedComponent />,
  document.getElementById('root'),
);
@Maushundb Maushundb changed the title connect throws an error when connecting a component wrapped in React.memo Connect throws an error when connecting a memoized component Oct 24, 2018
@markerikson
Copy link
Contributor

markerikson commented Oct 24, 2018

Duplicate of #914 . This will be fixed in React-Redux 6.0. Please try out our current WIP branches at #995 and #1000 to see if they work okay, available on NPM as tags next-995 and next-1000. I'll close this, but go ahead and comment here to let us know if they fix the issue for you.

(It's actually entirely possible they might not work right here - we might need to rebuild against React 16.6+ / a current version of react-is, in case we need to pick up the code that indicates that "memo" is a valid component type.)

@Maushundb
Copy link
Author

The next-1000 tag does NOT seem to fix my issue, unfortunately. Thanks for the timely response regardless!

@markerikson
Copy link
Contributor

Okay, thanks for the info.

I'm reconsidering this a bit - it may be worth putting out a 5.0.8 / 5.1.0 build that only switches to use of react-is, as an interim change.

@ddzy
Copy link

ddzy commented Dec 25, 2018

After upgrading my project to React 16.6.0 and migrating components to React.memo instead of Recompose.pure, connect is throwing an error when passed a memoized component:

Uncaught Error: You must pass a component to the function returned by connect. Instead received {"compare":null}

Repro:

const mapStateToProps = () => ({});
const MyComponent = React.memo(() => <div />);
const MyConnectedComponent = connect(mapStateToProps)(MyComponent);
ReactDOM.render(
  <MyConnectedComponent />,
  document.getElementById('root'),
);

same issue

@markerikson
Copy link
Contributor

@ddzy : please provide a project that reproduces the issue, preferably in CodeSandbox.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants