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

Version 7: Connected components are objects instead functions #1223

Closed
radeno opened this issue Apr 9, 2019 · 5 comments
Closed

Version 7: Connected components are objects instead functions #1223

radeno opened this issue Apr 9, 2019 · 5 comments

Comments

@radeno
Copy link

radeno commented Apr 9, 2019

With react-redux 6 connected component was returned as function. eg:

ƒ Connect(props)

Instead version 7 returns it as object because react hooks:

{$$typeof: Symbol(react.memo), type: ƒ, compare: null, WrappedComponent: ƒ, displayName: "Connect(Component)", …}

I think this should be noted for developers with PropTypes module for type checking.

@th3fallen
Copy link

i came to report the same thing, it actually breaks react-router for anyone that hasnt made the jump to v4

@timdorr
Copy link
Member

timdorr commented Apr 9, 2019

This is because we use React.memo on the component. As a workaround, you can set the pure option to false, which comes with a performance penalty.

@radeno
Copy link
Author

radeno commented Apr 9, 2019

@timdorr We dont have any contra arguments. But it is breaking change and should be noted

@markerikson
Copy link
Contributor

This is not a breaking change to our public APIs.

As of React 16.6, special component types like React.memo() are objects, not functions. Any code that assumed a React component can only be a function is wrong, and has been wrong since 16.6 came out.

I'll update the release notes accordingly, but this is an incorrect assumption on the part of the other libraries.

@timdorr
Copy link
Member

timdorr commented Apr 9, 2019

We handle this correctly in React Router 5, FWIW.

@reduxjs reduxjs deleted a comment from snehil-12 Sep 17, 2021
@reduxjs reduxjs locked as resolved and limited conversation to collaborators Sep 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants