-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
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
[DatePicker] Replace withDefaultProps with useThemeProps #24309
Conversation
AllSharedDateRangePickerProps<TDate> & | ||
PublicWrapperProps<TWrapper>, | ||
) { | ||
const propsWithDefault = useThemeProps({ props, name }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use the shortest name for the one that should be used throughout the component. I propose we use inputProps
for the function parameter and then props
for the final object.
That way we don't constantly have to change the actual implementation (e.g. by renaming variables).
inputProps
is already used in other places and recognized by some internal static analysis tools.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, I think that we should use the existing naming convention:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disregard #24309 (comment) since there's no reason given. The name should be inputProps
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no reason given
The initial comment was using the consistency argument.
Regarding why @mnajdova used this naming convention, if I had to guess I would assume:
- to minimize the diff during the refactoring.
- to keep the rendering logic idiomatic (to use "prop").
But best to ask her.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll follow #24309 (comment). Does everyone agree? I found more occurrences of inputProps
than inProps
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eps1lon I don't have a preference in the final name we pick (Marija used two different names, so she has an internal conflict about what's better too 😄). I think that we should resolve this question once for all. This is why I think normalizing to a single name is important (and no, not important enough to have a rule in the CI). Once it's the case, developers can follow what the majority does. They can copy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we should resolve this question once for all. This is why I think normalizing to a single name is important (and no, not important enough to have a rule in the CI)
There's no reason given from your part. You just applied circular logic: "I think we should resolve it, therefore we should change it".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eps1lon Ok, I can be clearer: "the same solution should be applied to the same problems", this is an axiom. I think we can all agree on it. I think that we should also extend it to "until proven otherwise, problems are identical", which aims to minimize entropy, it helps move things forward as a single consistent "block", to be more effective and efficient, to force confrontation of opposite ideas.
Then comes this specific case. I think that we should make a case for why different names need to be used (why it's a different problem that require a different solution), not the opposite.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't care. Just don't break existing code and use inputProps
where the name is required, thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated this PR to reflect the changes you all requested. In the end I ended up using inProps
because inputProps
was already being used. I don't think this PR is the best place to discuss these things. If consistency is a big concern let's open a RFC to discuss this and other inconsistencies. It would be nice to enrich the API Design page with variable naming conventions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to see this bug taking care of :)
AllSharedDateRangePickerProps<TDate> & | ||
PublicWrapperProps<TWrapper>, | ||
) { | ||
const propsWithDefault = useThemeProps({ props, name }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, I think that we should use the existing naming convention:
Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
…est.tsx Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
@@ -90,7 +91,7 @@ export function makePickerWithStateAndWrapper< | |||
); | |||
} | |||
|
|||
const FinalPickerComponent = withDefaultProps({ name }, withDateAdapterProp(PickerWithState)); | |||
const FinalPickerComponent = withDateAdapterProp(PickerWithState); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a proposal to drop this HOC too in #23670.
@@ -1,6 +1,6 @@ | |||
import * as React from 'react'; | |||
import { useThemeProps } from '@material-ui/core/styles'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a proposal to expose it as unstable in #24307.
@m4theushw Well done :) |
Fixes #23675