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

Error in fragment #458

Closed
jaydenseric opened this issue Jun 29, 2018 · 5 comments
Closed

Error in fragment #458

jaydenseric opened this issue Jun 29, 2018 · 5 comments

Comments

@jaydenseric
Copy link
Contributor

Do you want to request a feature or report a bug?

Bug.

What is the current behavior?

Styled JSX inside a React Fragment container causes a rendering error.

If the current behavior is a bug, please provide the steps to reproduce and possibly a minimal demo or testcase in the form of a Next.js app, CodeSandbox URL or similar

Mounting this component:

const Test = () => (
  <>
    <p>Test</p>
    <style jsx>{`
      p {
        color: red;
      }
    `}</style>
  </>
)

Causes this error:

Warning: Received `true` for a non-boolean attribute `jsx`.

What is the expected behavior?

No rendering error.

Environment (include versions)

  • OS: macOS
  • Browser: Chrome v67.0.3396.99
  • styled-jsx (version): v2.2.6
  • next (version): v6.1.0

Did this work in previous versions?

There were other bugs with fragments which have since been closed.

@giuseppeg
Copy link
Collaborator

styled-jsx is not compatible with Babel7 yet but it would probably as simple as also visiting JSXFragment like we do for JSXElement

@madeleineostoja
Copy link

Any update on this?

And is the incompatibility with Babel 7 documented anywhere? Just lost hours trying to debug this before figuring out it was the new Fragment syntax that was causing it.

sindresorhus added a commit to atomiclabs/hyperdex that referenced this issue Sep 1, 2018
@jaydenseric
Copy link
Contributor Author

jaydenseric commented Sep 7, 2018

Can this please be escalated to bug status? It makes no sense that this will work:

import { Fragment } from 'react'

const Logo = () => (
  <Fragment>
    <img src="/static/logo.svg" />
    <style jsx>{`
      img {
        border-radius: 50%;
      }
    `}</style>
  </Fragment>
)

... and this legitimate syntax (supported by stable React and Babel) won't:

const Logo = () => (
  <>
    <img src="/static/logo.svg" />
    <style jsx>{`
      img {
        border-radius: 50%;
      }
    `}</style>
  </>
)

@giuseppeg
Copy link
Collaborator

We need to make a patch release before starting to work on v4 and switch to babel 7. I don’t do this for a living so sometimes things can be slower. If any bugfix or feature is crucial for your work I welcome any contribution and I’d be happy to give guidance and help

@Soundvessel
Copy link

A heads up (see referenced issue above) that this bug resurfaced when using the styled-jsx-plugin-sass plugin.

ijjk added a commit to ijjk/styled-jsx that referenced this issue Jan 1, 2019
and added support for React Fragments (fixes vercel#458)
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

5 participants