question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

skipSx should update shouldForwardProps

See original GitHub issue

Duplicates

  • 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:open
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
michaldudakcommented, Mar 3, 2022

It would be a breaking change, though, so we could think about it for the v6 release.

1reaction
mnajdovacommented, Mar 2, 2022

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 default shouldForwardProp. But, if a custom shouldForwardProp function is specified, it should be a responsibility of the developer to decide on it. I am not sure if this is very intuitive.

Read more comments on GitHub >

github_iconTop 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 >

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