-
Notifications
You must be signed in to change notification settings - Fork 36
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
fix(resize-handle): make ref callback stable #214
fix(resize-handle): make ref callback stable #214
Conversation
@@ -48,7 +48,7 @@ export type UseResizeHandleParams = { | |||
* A function that will be called to get the value that will be set as the aria-valuetext attribute on the resize handle. | |||
* Use this for localization. | |||
*/ | |||
getA11ValueText?: (value: number) => string; | |||
getA11ValueText?: (value: number) => string | undefined; |
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.
This actually allows undefined
, the default impl also returns undefined
.
const handleChange: UseResizeHandleParams['onChange'] = useEventCallback( | ||
(value) => { | ||
onChange?.(value); | ||
} | ||
); |
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 need to use useEventCallback()
callback there, otherwise we make memoization an implicit contract
@@ -68,8 +72,7 @@ export const useResizeHandle = (params: UseResizeHandleParams) => { | |||
onChange, | |||
onDragStart, | |||
onDragEnd, | |||
getA11ValueText = (value) => | |||
value === UNMEASURED ? undefined : `${value.toFixed(0)}px`, | |||
getA11ValueText = DEFAULT_GET_A11_VALUE_TEXT, |
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.
getA11ValueText
before was unstable reference
This reverts commit 09e0824.
See comments on code.