-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[docs] Improve documentation to cover shouldForwardProp #21318
Comments
Since it appears this issue has not yet been claimed, I would love to take a stab at it! I've been using helper functions to implement the same functionality before realizing it was an undocumented part of It seems like adding similar functionality to |
@jdkula We have been withholding all investment on the styling solution since v4 came out. One likely path is that we will dump it all. Until we know the direction we take, let's hold (applies for all |
@oliviertassinari can you elaborate on what you mean by "dump it all", or point me to a discussion on the topic? That sounds like you're considering removing JSS entirely from the project - we're trying to decide between JSS and CSS Modules for my next project, and what MaterialUI uses is a non-zero part of that discussion. |
We can close once our new |
An update, this issue is being resolved in v5 thanks to #22342 and the new We are normalizing with the emotion's import * as React from "react";
import { experimentalStyled as styled } from "@material-ui/core/styles";
interface BoxProps {
foo: string;
}
const Box = styled("div", {
shouldForwardProp: (prop) => prop !== "foo"
})(({ foo }: BoxProps) => ({
backgroundColor: foo
}));
export default function UnstyledSlider() {
return <Box foo="#000" style={{ width: 30, height: 30 }} />;
} https://codesandbox.io/s/unstyledslider-material-demo-forked-rdp6p?file=/demo.tsx The |
filterProps
on styled()filterProps
on styled()
filterProps
on styled()
I have repurposed the issue to cover v5 (instead of v4). We can:
|
Should we consider this solved, now that we have https://next.material-ui.com/customization/styled/? |
I've been having issues with the following code:
The attribute
color="red"
gets added to the<div>
in the DOM. Nothing in the documentation told me how to fix this. Some fixes on Stackoverflow or Spectrum.chat look like this:but this is messy, and removes the Typescript typings that
Box
has when doingstyled('div')
.I dug around in the source code of
styled()
, and it turns out there is afilterProps
property I can use:This works great! Exactly what I need. However, a few problems:
options
object as a 2nd parameter:Implementing this change would be very simple:
useStyles()
call, and change it to this:Since this field isn't documented, you could argue that moving it isn't a breaking change, since this isn't part of the public interface. However, it's probably better to:
options
object, but also allow it to still be specified in the style blockconsole.warn()
deprecation message in the console whenNODE_ENV !== 'production'
The text was updated successfully, but these errors were encountered: