Skip to content
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

Merged
merged 5 commits into from
Jan 12, 2021

Conversation

m4theushw
Copy link
Member

Fixes #23675

@mui-pr-bot
Copy link

mui-pr-bot commented Jan 8, 2021

Details of bundle changes

Generated by 🚫 dangerJS against 72cf4ce

AllSharedDateRangePickerProps<TDate> &
PublicWrapperProps<TWrapper>,
) {
const propsWithDefault = useThemeProps({ props, name });
Copy link
Member

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.

Copy link
Member

@oliviertassinari oliviertassinari Jan 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

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.

Copy link
Member

@oliviertassinari oliviertassinari Jan 8, 2021

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:

  1. to minimize the diff during the refactoring.
  2. to keep the rendering logic idiomatic (to use "prop").

But best to ask her.

Copy link
Member Author

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.

Copy link
Member

@oliviertassinari oliviertassinari Jan 9, 2021

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.

Copy link
Member

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".

Copy link
Member

@oliviertassinari oliviertassinari Jan 10, 2021

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.

Copy link
Member

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.

Copy link
Member Author

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.

@oliviertassinari oliviertassinari added component: date picker This is the name of the generic UI component, not the React module! bug 🐛 Something doesn't work labels Jan 8, 2021
Copy link
Member

@oliviertassinari oliviertassinari left a 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 });
Copy link
Member

@oliviertassinari oliviertassinari Jan 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m4theushw and others added 3 commits January 10, 2021 14:01
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);
Copy link
Member

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';
Copy link
Member

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.

@oliviertassinari oliviertassinari merged commit 6b18675 into mui:next Jan 12, 2021
@oliviertassinari
Copy link
Member

@m4theushw Well done :)

@m4theushw m4theushw deleted the useThemeProps branch April 15, 2021 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: date picker This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DatePicker] Theme default props broken
4 participants