Warning: Invalid prop `className` supplied to `React.Fragment`

See original GitHub issue

Bug report

Describe the bug

When using React.Fragment like this:

import React from "react";

export default function Page() {
  const X = React.Fragment;
  return (
    <div>
      <style jsx global>{`
        html {
          margin: 0;
        }
      `}</style>
      <X>Hello</X>
    </div>
  );
}

You get this warning from React in the console:

Warning: Invalid prop `className` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.

To Reproduce

CodeSandbox: https://codesandbox.io/s/adoring-wescoff-udecy?file=/pages/index.js

Tested with Next 9.6.0 and 10.0.1

Feel free to transfer the issue to the styled-jsx repo if it makes more sense

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
lachlanjccommented, Nov 18, 2020

This issue is already being tracked https://github.com/vercel/styled-jsx/issues/648 & is part of that library šŸ‘

0reactions
balazsorban44commented, Jan 29, 2022

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React error : Invalid prop `class` supplied to React.Fragment
It seems to be a small syntax error, your final return statement should be : return ( <div> <Helmet title={`Post | ${title}`} />...
Read more >
React Fragment warning - JSFiddle - Code Playground
Invalid prop `className` supplied to `React.Fragment`. React. ... class App extends React.Component { ... class Foo extends React.Component {.
Read more >
Fragments - React
Fragments let you group a list of children without adding extra nodes to the DOM. ... the render() of <Columns /> , then...
Read more >
Understanding React fragments - LogRocket Blog
This tutorial is designed to help you understand React fragments and various use cases where they come in handy. Here's what we'll cover:....
Read more >
Warning: Failed prop type: Invalid prop `children` supplied to ...
Warning : Failed prop type: Invalid prop `children` supplied to `ForwardRef(…)`, expected a ReactNode. ... Material UI⁓.11, React¹⁷.0.2, Created atĀ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found