diff --git a/packages/react-native/Libraries/Components/Button.js b/packages/react-native/Libraries/Components/Button.js index f61d1bb01ffd..12c1b532aece 100644 --- a/packages/react-native/Libraries/Components/Button.js +++ b/packages/react-native/Libraries/Components/Button.js @@ -156,22 +156,30 @@ type ButtonPropsCore = Readonly<{ accessibilityLanguage?: ?Stringish, }>; -/** @build-types emit-as-interface Uniwind compatibility */ +/** + * Button is deprecated and will be removed in a future release. + * Build your own button with `Pressable` instead. + * @see https://reactnative.dev/docs/pressable + * @deprecated + * @build-types emit-as-interface Uniwind compatibility + */ export type ButtonProps = ButtonPropsCore; const NativeTouchable: typeof TouchableNativeFeedback | typeof TouchableOpacity = Platform.OS === 'android' ? TouchableNativeFeedback : TouchableOpacity; +/** + * Button is deprecated and will be removed in a future release. + * Build your own button with `Pressable` instead. + * @deprecated + */ export type ButtonInstance = React.ElementRef; /** * A basic button component that should render nicely on any platform. Supports a * minimal level of customization. * - * If this button doesn't look right for your app, you can build your own button - * using `Pressable`. - * * Example: * * ```tsx @@ -183,7 +191,11 @@ export type ButtonInstance = React.ElementRef; * /> * ``` * - * @see https://reactnative.dev/docs/button + * Button is deprecated and will be removed in a future release. + * Build your own button with `Pressable` instead. + * + * @see https://reactnative.dev/docs/pressable + * @deprecated */ const Button: component( ref?: React.RefSetter, diff --git a/packages/react-native/index.js b/packages/react-native/index.js index 73f16e7dd219..065f9c839a74 100644 --- a/packages/react-native/index.js +++ b/packages/react-native/index.js @@ -34,8 +34,19 @@ module.exports = { return require('./Libraries/Components/ActivityIndicator/ActivityIndicator') .default; }, + /** + * @deprecated Button is deprecated and will be removed in a future release. + * Build your own button with Pressable instead. + * See https://reactnative.dev/docs/pressable + */ // $FlowFixMe[unsafe-getters-setters] get Button() { + warnOnce( + 'button-deprecated', + 'Button is deprecated and will be removed in a future release. ' + + 'Build your own button with Pressable instead. ' + + 'See https://reactnative.dev/docs/pressable', + ); return require('./Libraries/Components/Button').default; }, /** diff --git a/packages/rn-tester/js/examples/SafeAreaInsets/SafeAreaInsetsExample.js b/packages/rn-tester/js/examples/SafeAreaInsets/SafeAreaInsetsExample.js index ed8dfab585a4..b6c8fcbe42a2 100644 --- a/packages/rn-tester/js/examples/SafeAreaInsets/SafeAreaInsetsExample.js +++ b/packages/rn-tester/js/examples/SafeAreaInsets/SafeAreaInsetsExample.js @@ -13,11 +13,11 @@ import type {RNTesterModuleExample} from '../../types/RNTesterTypes'; import type {SafeAreaInsetsChangeEvent} from 'react-native'; +import RNTesterButton from '../../components/RNTesterButton'; import RNTesterText from '../../components/RNTesterText'; import * as React from 'react'; import {useCallback, useState} from 'react'; import { - Button, Modal, Platform, ScrollView, @@ -105,13 +105,15 @@ function FullScreenModalContent({onClose}: {onClose: () => void}): React.Node { the same frame, without the content jumping. {!applied ? ( -