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

[fields] Improve useSplitFieldProps and make it public #14514

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Sep 6, 2024

Extracted from #14486
Closes #14515

Work

  • Improve the typing to remove the TInternalProps generic (makes the whole DX a lot lighter)
  • Turn splitFieldInternalAndForwardedProps into a hook so that the computation does not re-occur when the component has a re-render that is not caused by a prop change (it has a lot of re-renders caused by state update inside useField)
  • Move the new hook to @mui/x-date-pickers/hooks
  • Add some JSDoc

@flaviendelangle flaviendelangle self-assigned this Sep 6, 2024
@flaviendelangle flaviendelangle added the component: pickers This is the name of the generic UI component, not the React module! label Sep 6, 2024
@mui-bot
Copy link

mui-bot commented Sep 6, 2024

Deploy preview: https://deploy-preview-14514--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against 2135d08

@flaviendelangle flaviendelangle force-pushed the useSplitFieldInternalAndForwardedProps branch from 40bb070 to a5a6d79 Compare September 6, 2024 08:57
@flaviendelangle flaviendelangle changed the title [pickers] Improve useSplitFieldInternalAndForwardedProps and make it public [fields] Improve useSplitFieldInternalAndForwardedProps and make it public Sep 6, 2024
@flaviendelangle flaviendelangle marked this pull request as ready for review September 6, 2024 09:18
Copy link
Member

@LukasTy LukasTy left a comment

Choose a reason for hiding this comment

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

Great work! 👍

Comment on lines 44 to 51
export const useSplitFieldInternalAndForwardedProps = <
TValueType extends FieldValueType,
TProps extends { [key in InternalPropNames<TValueType>]?: any },
>(
props: TProps,
valueType: TValueType,
) => {
return React.useMemo(() => {
Copy link
Member

Choose a reason for hiding this comment

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

Awesome improvements (typing and memoization)! 💙 💯 🙌

@flaviendelangle flaviendelangle changed the title [fields] Improve useSplitFieldInternalAndForwardedProps and make it public [fields] Improve useSplitFieldProps and make it public Sep 11, 2024
@flaviendelangle flaviendelangle merged commit 309106d into mui:master Sep 11, 2024
15 of 16 checks passed
@flaviendelangle flaviendelangle deleted the useSplitFieldInternalAndForwardedProps branch September 11, 2024 10:29
@LukasTy LukasTy mentioned this pull request Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pickers 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.

[fields] Make splitFieldInternalAndForwardedProps public
3 participants