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

Passing styled-components as props results in large snapshots #131

Open
jwld opened this issue Feb 18, 2019 · 1 comment
Open

Passing styled-components as props results in large snapshots #131

jwld opened this issue Feb 18, 2019 · 1 comment

Comments

@jwld
Copy link

jwld commented Feb 18, 2019

Happens when passing components created using the styled-components library as props.

For example:

<FieldWrap
  meta={Object {}}
  wrapper={
    Object {
      "$$typeof": Symbol(react.forward_ref),
      "attrs": Array [],
      "componentStyle": ComponentStyle {
        "componentId": "DefaultWrapper-sc-15lfxc7-0",
        "isStatic": true,
        "rules": Array [
          "align-items:center;display:flex;flex-direction:column;justify-content:flex-start;",
          ";",
        ],
      },
      "displayName": "DefaultWrapper",
      "foldedComponentIds": Array [],
      "render": [Function],
      "styledComponentId": "DefaultWrapper-sc-15lfxc7-0",
      "target": "div",
      "toString": [Function],
      "warnTooManyClasses": [Function],
      "withComponent": [Function],
    }
  }
>

This also has the nasty side effect of requiring a snapshot update whenever any of the styling rules on the prop being passed are changed. Would be nice if it just said Object {} instead!

Is there any way around this?

@jwld jwld changed the title Passing react components as props results in large snapshots Passing styled-components as props results in large snapshots Feb 18, 2019
@jwld
Copy link
Author

jwld commented Mar 14, 2019

Just for a bit more context, I noticed this became a problem on another project once I updated styled-components to v4, which seems to change the prop from a function to an object (this is the snapshot):

Screenshot 2019-03-14 at 13 25 32

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

No branches or pull requests

2 participants