skipSx should update shouldForwardProps
See original GitHub issueDuplicates
- I have searched the existing issues
Latest version
- I have tested the latest version
Summary 💡
The skipSx
doesn’t work as expected when shouldForwardProp
default mechanism is overwritten and does not include 'sx'
directly
shouldForwardProp: (prop) => !["isEven"].includes(prop as string),
skipSx: true
This will send sx
to the underlying component
Examples 🌈
I made a code sandbox using the latest released material
https://codesandbox.io/s/goofy-phoebe-xc99x
Motivation 🔦
making a custom component that only changes in CSS layer duo to props is a common practice also, sx seems to be a little bit slow, and skipping it may gain some performance tips
so because we are working mostly with the Mui component and they pass the props to the underling dom node, it makes sense to have it as a core feature of the material
I seared on skipSx
tags in the issue list and could not find an open issue, so posted a new one.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top Results From Across the Web
styled-system/should-forward-prop
Utility for filtering Styled System props with Emotion's shouldForwardProp option. Latest version: 5.1.5, last published: 3 years ago.
Read more >styled() - MUI System
It adds support for the the sx prop (can be skipped). It adds by default the shouldForwardProp option (that can be overridden), taking...
Read more >Custom Icon components in MUI v5
Here, I use name and shouldForwardProp options to set a name for our new SvgIcon Component and also shouldForwardProp to say which property ......
Read more >shouldForwardProp
To seamingly implement the shouldForwardProp without the need to provide the full loop over props you can use the goober/should-forward-prop addon.
Read more >The Essential Guide to MUI Styled Components
This guide to using Styled Components with Material-UI will explain the new API, what imports are required, ... 3.1 MUI shouldForwardProp.
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 FreeTop 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
Top GitHub Comments
It would be a breaking change, though, so we could think about it for the v6 release.
After reading trough it I think it makes sense for the
skipSx
prop to determine whether to forward the sx prop or not. I think we should combine this logic with the defaultshouldForwardProp
. But, if a customshouldForwardProp
function is specified, it should be a responsibility of the developer to decide on it. I am not sure if this is very intuitive.