diff --git a/src/components/Button/Button.tsx b/src/components/Button/Button.tsx index 246e93e1a3..21bd9f580e 100644 --- a/src/components/Button/Button.tsx +++ b/src/components/Button/Button.tsx @@ -15,6 +15,7 @@ import color from 'color'; import { ButtonMode, getButtonColors } from './utils'; import { useInternalTheme } from '../../core/theming'; import type { $Omit, ThemeProp } from '../../types'; +import { forwardRef } from '../../utils/forwardRef'; import hasTouchHandler from '../../utils/hasTouchHandler'; import { splitStyles } from '../../utils/splitStyles'; import ActivityIndicator from '../ActivityIndicator'; @@ -149,34 +150,37 @@ export type Props = $Omit, 'mode'> & { * export default MyComponent; * ``` */ -const Button = ({ - disabled, - compact, - mode = 'text', - dark, - loading, - icon, - buttonColor: customButtonColor, - textColor: customTextColor, - rippleColor: customRippleColor, - children, - accessibilityLabel, - accessibilityHint, - onPress, - onPressIn, - onPressOut, - onLongPress, - delayLongPress, - style, - theme: themeOverrides, - uppercase: uppercaseProp, - contentStyle, - labelStyle, - testID = 'button', - accessible, - maxFontSizeMultiplier, - ...rest -}: Props) => { +const Button = ( + { + disabled, + compact, + mode = 'text', + dark, + loading, + icon, + buttonColor: customButtonColor, + textColor: customTextColor, + rippleColor: customRippleColor, + children, + accessibilityLabel, + accessibilityHint, + onPress, + onPressIn, + onPressOut, + onLongPress, + delayLongPress, + style, + theme: themeOverrides, + uppercase: uppercaseProp, + contentStyle, + labelStyle, + testID = 'button', + accessible, + maxFontSizeMultiplier, + ...rest + }: Props, + ref: React.ForwardedRef +) => { const theme = useInternalTheme(themeOverrides); const isMode = React.useCallback( (modeToCompare: ButtonMode) => { @@ -295,6 +299,7 @@ const Button = ({ return ( = ForwardRefExoticComponent< +export type ForwardRefComponent = ForwardRefExoticComponent< PropsWithoutRef

& RefAttributes >; /** * TypeScript generated a large union of props from `ViewProps` in * `d.ts` files when using `React.forwardRef`. To prevent this - * `ForwarRefComponent` was created and exported. Use this + * `ForwardRefComponent` was created and exported. Use this * `forwardRef` instead of `React.forwardRef` so you don't have to - * import `ForwarRefComponent`. + * import `ForwardRefComponent`. * More info: https://github.com/callstack/react-native-paper/pull/3603 */ export const forwardRef: ( render: ForwardRefRenderFunction -) => ForwarRefComponent = React.forwardRef; +) => ForwardRefComponent = React.forwardRef;