React warning using styled function
See original GitHub issue- This is not a v0.x issue.
- I have searched the issues of this repository and believe that this is not a duplicate.
Expected Behavior 🤔
Using the following code snippet
export const styledBy = (property, mapping) => props =>
mapping[props[property]];
const AppBarContent = styled('div')({
flexGrow: 1,
display: 'flex',
justifyContent: styledBy('alignContent', {
start: 'flex-start',
end: 'flex-end',
center: 'center',
}),
});
// ....
<AppBarContent alignContent={props.alignContent}>
{props.children}
</AppBarContent>
Current Behavior 😯
index.js:1437 Warning: React does not recognize the alignContent
prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase aligncontent
instead. If you accidentally passed it from a parent component, remove it from the DOM element.
Steps to Reproduce 🕹
Link: https://github.com/straw-hat-team/react-admin
yarn start
- Notice the console error
Context 🔦
Your Environment 🌎
Tech | Version |
---|---|
Material-UI | 4.0.0-beta.1 |
React | 16.8.6 |
Browser | |
TypeScript | 3.4.5 |
etc. |
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:11 (7 by maintainers)
Top Results From Across the Web
React warning using styled function #15614 - mui/material-ui
I had a new look at the issue. emotion and styled-components report a warning, shouldForwardProp is supported by both. You can use the...
Read more >Getting warning from props passed in MUI styled components ...
Warning : React does not recognize the isLarge prop on a DOM element. If you intentionally want it to appear in the DOM...
Read more >You may see this warning because you've called styled inside ...
The component styled.div with the id of “sc-fzplWN” has been created dynamically. You may see this warning because you've called styled ...
Read more >FAQs - styled-components
The warning message below indicates that non-standard attributes are being attached to HTML DOM elements such as <div> or <a>. If you are...
Read more >How to use styled components with Material UI in a React app
The styled() method from styled-components takes as input a React component and outputs another React component with a different style. It is ...
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
I think that I’m missing something; is there any way to stop forwarding props to an html element (such as div), while still using
styled()
. I can see how to do it with makeStyles/useStyles since you get explicit control of what gets passed to your div, but not when using styled.It is as simple as, don’t pass props to styled html elements?
import styled from "styled-components"
doesn’t have this problem, butimport {styled} from "@mui/material"
still giving this warning. Any official solution?