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

Added test showing that styled-calls yield non-functions #2196

Closed
wants to merge 1 commit into from
Closed

Added test showing that styled-calls yield non-functions #2196

wants to merge 1 commit into from

Conversation

gertsonderby
Copy link

I ran into some issues wrt. testing that seemed to be caused by styled components not being JS function type, somehow. Test replication was very easy - a simple styled component is of type 'object'! A quick look at the constructors used did not yield an immediately obvious source, so I submit it here.

@kachkaev
Copy link
Member

kachkaev commented Nov 9, 2018

@gertsonderby the reason why SC are objects is because they are wrapped into React.forwardRef. Why seeing them as functions it necessary for you?

@joeegan
Copy link

joeegan commented Nov 9, 2018

One reason would be react-redux connect compatibility.

@kachkaev
Copy link
Member

kachkaev commented Nov 9, 2018

Could you please provide an example that does not work for you now?

@joeB2C2
Copy link

joeB2C2 commented Nov 9, 2018

Slightly more details here: https://spectrum.chat/thread/9b5cc71e-100e-4380-a976-b40166332896

@mxstbr
Copy link
Member

mxstbr commented Nov 9, 2018

As @kachkaev correctly stated, styled components are not functions due to React.forwardRef being used, which returns an object. If that bothers you for whatever reason, please submit an issue with React itself and discuss whether React.forwardRef can use a function under the hood!

One reason would be react-redux connect compatibility.

react-redux has to add support for React.forwardRef components, there's nothing we can do from our side to help this.

@mxstbr mxstbr closed this Nov 9, 2018
@joeB2C2
Copy link

joeB2C2 commented Nov 9, 2018

OK cool, I'll try and get round to raising a PR for react-redux

@mxstbr
Copy link
Member

mxstbr commented Nov 9, 2018

It seems like they recently did, see reduxjs/react-redux#914

Might just have to upgrade!

@gertsonderby gertsonderby deleted the bug/component-js-type branch November 9, 2018 11:55
@joeB2C2
Copy link

joeB2C2 commented Nov 9, 2018

Excellent, thanks for looking into it

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

Successfully merging this pull request may close these issues.

None yet

5 participants