From 2ab34cf43ea0f33e48355c5a63dc20a6748fe43a Mon Sep 17 00:00:00 2001 From: Fabrizio Cucci <fabriziocucci@meta.com> Date: Mon, 13 Jan 2025 08:12:17 -0800 Subject: [PATCH] Migrate rn-tester/js/components/RNTesterButton.js to function components (#48645) Summary: As per title. Changelog: [Internal] Reviewed By: cortinico Differential Revision: D68098118 --- .../rn-tester/js/components/RNTesterButton.js | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/packages/rn-tester/js/components/RNTesterButton.js b/packages/rn-tester/js/components/RNTesterButton.js index d760b3a00ea230..a53385d6f89854 100644 --- a/packages/rn-tester/js/components/RNTesterButton.js +++ b/packages/rn-tester/js/components/RNTesterButton.js @@ -12,8 +12,7 @@ import type {PressEvent} from 'react-native/Libraries/Types/CoreEventTypes'; -const React = require('react'); -const {Pressable, StyleSheet, Text} = require('react-native'); +import {Pressable, StyleSheet, Text} from 'react-native'; type Props = $ReadOnly<{| testID?: string, @@ -22,17 +21,15 @@ type Props = $ReadOnly<{| onPress?: ?(event: PressEvent) => mixed, |}>; -class RNTesterButton extends React.Component<Props> { - render(): React.Node { - return ( - <Pressable - testID={this.props.testID} - onPress={this.props.onPress} - style={({pressed}) => [styles.button, pressed && styles.pressed]}> - <Text testID={this.props.textTestID}>{this.props.children}</Text> - </Pressable> - ); - } +function RNTesterButton(props: Props): React.Node { + return ( + <Pressable + testID={props.testID} + onPress={props.onPress} + style={({pressed}) => [styles.button, pressed && styles.pressed]}> + <Text testID={props.textTestID}>{props.children}</Text> + </Pressable> + ); } const styles = StyleSheet.create({ @@ -51,4 +48,4 @@ const styles = StyleSheet.create({ }, }); -module.exports = RNTesterButton; +export default RNTesterButton;