-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
feat(bindings): add useUnhandledProps hook #12371
Conversation
Perf AnalysisNo significant results to display. All results
Perf Analysis (Fluent)Perf comparison
Perf tests with no regressions
|
Asset size changesSize Auditor did not detect a change in bundle size for any component! Baseline commit: 13e558c9ff85536a1ce1b06d4816b78fab2ec7be (build) |
* @param props - A ReactElement props object | ||
* @returns A shallow copy of the prop object | ||
*/ | ||
function useUnhandledProps<P extends Record<string, any>>(handledProps: (keyof P)[], props: P): Partial<P> { |
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.
Can we add example in the react-bindings README? Or do you consider this as an internal hook?
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.
Added 👍
@@ -15,6 +15,7 @@ export { default as unstable_useDispatchEffect } from './hooks/useDispatchEffect | |||
export { default as useIsomorphicLayoutEffect } from './hooks/useIsomorphicLayoutEffect'; | |||
export { default as useStateManager } from './hooks/useStateManager'; | |||
export { default as useStyles } from './hooks/useStyles'; | |||
export { default as useUnhandledProps } from './hooks/useUnhandledProps'; |
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.
As we are exporting it, I believe it deserves changelog entry
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, added
@@ -231,7 +231,7 @@ const Animation: React.FC<AnimationProps> & { | |||
const { animationDuration, animationDelay } = animationStyles.root; | |||
const timeoutResult = timeout || calculateAnimationTimeout(animationDuration, animationDelay) || 0; | |||
|
|||
const unhandledProps = getUnhandledProps(Animation.handledProps, props); | |||
const unhandledProps = useUnhandledProps(Animation.handledProps, props); |
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.
Should we use the generic typings?
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.
Nope, they will be inferred as it was previously for getUnhandledProps
…/github.com/OfficeDev/office-ui-fabric-react into feat/add-use-unhandled-props
…/github.com/OfficeDev/office-ui-fabric-react into feat/add-use-unhandled-props � Conflicts: � packages/fluentui/CHANGELOG.md � packages/fluentui/react-bindings/README.md
Pull request checklist
$ yarn change
Description of changes
This PR adds
useUnhandledProps()
hook to replacegetUnhandledProps()
function in functional components. Functionality ofuseUnhandledProps()
will be changed incompose()
PR.Microsoft Reviewers: Open in CodeFlow