-
-
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
[material-ui][docs] Fade (and other transition helpers) fails silently when children aren't able to receive the style prop #15472
Comments
Sounds tempting but we try to avoid a div soup. I think this makes this even harder in certain layouts
That doesn't solve the issue. The user can still drop the passed I'm not sure we should add warnings here if we don't see the styles. We cannot know where/how the child treats the style. It might even actually want to drop them. We can improve the docs and explicitly document what props we pass to the child and expect it to handle. Adding warnings doesn't seem viable. |
I think it can make sense, since the functionality depends on
True although I think its less of a risk since you can type the function to take the styles. We got bit by this bug because of a refactoring that changed the root element to a fragment and suddenly the fades stopped working. If we had a render prop that takes a style prop I think we would have discovered this regression when refactoring.
I cant think of a use case for using the
I hope it can be enforced programatically and/or with api design aswell. |
This is true for every refactoring in react where parent-child are tightly coupled. Maybe TypeScript will address some of the JSX issues but I don't see how we can check this at runtime.
It's not about the if but about the when. And then we have to solve how we verify if the style is actually the style we want i.e. how to determine if some CSSDeclaration is a subset of another and if we should warn in every case. This would definitely improve DX but it's a very niche case. If you can provide a concrete implementation I'm happy to review it. |
That is why I want the requirments that
Would be nice. This issue might help this: microsoft/TypeScript#21699
What happened with this suggestion, I dont think you adressed it :) :
|
If it receives a component through the |
Expected Behavior 🤔
That the
Fade
component complains if it getschildren
that doesnt take the style prop.Current Behavior 😯
If you give
Fade
an element that doesnt take and apply thestyle
prop theFade
component does nothing.See this codesandbox: https://codesandbox.io/s/n3z26zp6n0 There you can see the the component that returns a
React.Fragment
the root never fades but the one with adiv
does.Here are some suggestions/thoughts/options:
style
prop (via typescript types and/or prop-types)Component
prop and render that instead of receiving an element and doing cloneElement. I think there is some problems typing react elements, see thisThe text was updated successfully, but these errors were encountered: