Warning: Invalid prop `className` supplied to `React.Fragment`
See original GitHub issueBug 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:
- Created 3 years ago
- Comments:7 (6 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This issue is already being tracked https://github.com/vercel/styled-jsx/issues/648 & is part of that library š
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.