Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
*/

import type * as React from 'react';
import {Constructor} from '../../../types/private/Utilities';
import {TimerMixin} from '../../../types/private/TimerMixin';
import {NativeMethods} from '../../../types/public/ReactNativeTypes';
import {TouchableMixin} from './Touchable';
import {View} from '../../Components/View/View';
import {TouchableWithoutFeedbackProps} from './TouchableWithoutFeedback';

export interface TVProps {
Expand Down Expand Up @@ -79,14 +76,6 @@ export interface TouchableOpacityProps
*
* @see https://reactnative.dev/docs/touchableopacity
*/
declare class TouchableOpacityComponent extends React.Component<TouchableOpacityProps> {}
declare const TouchableOpacityBase: Constructor<TimerMixin> &
Constructor<TouchableMixin> &
Constructor<NativeMethods> &
typeof TouchableOpacityComponent;
export class TouchableOpacity extends TouchableOpacityBase {
/**
* Animate the touchable to a new opacity.
*/
setOpacityTo: (value: number) => void;
}
export const TouchableOpacity: React.ForwardRefExoticComponent<
React.PropsWithoutRef<TouchableOpacityProps> & React.RefAttributes<View>
>;
17 changes: 17 additions & 0 deletions packages/react-native/types/__typetests__/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,26 @@ function TouchableTest() {
}

export class TouchableOpacityTest extends React.Component {
buttonRef = React.createRef<React.ElementRef<typeof TouchableOpacity>>();

render() {
return (
<>
<TouchableOpacity ref={this.buttonRef} />
<TouchableOpacity
ref={ref => {
ref?.focus();
ref?.blur();
ref?.measure(
(x, y, width, height, pageX, pageY): number =>
x + y + width + height + pageX + pageY,
);
ref?.measureInWindow(
(x, y, width, height): number => x + y + width + height,
);
ref?.setNativeProps({focusable: false});
}}
/>
<TouchableOpacity focusable={false} />
<TouchableOpacity rejectResponderTermination={true} />
<TouchableOpacity
Expand Down