mirror of
https://github.com/status-im/react-native.git
synced 2025-02-05 06:04:15 +00:00
Button: Remove PropTypes (#21280)
Summary: Part of: https://github.com/react-native-community/discussions-and-proposals/issues/29 This PR removes the `prop-types` from the `Button` component, and cleans up its flow type definitions. Pull Request resolved: https://github.com/facebook/react-native/pull/21280 Differential Revision: D10007108 Pulled By: TheSavior fbshipit-source-id: 6206f7e8aab5b56abc5e8e0790a1020494eb2bf0
This commit is contained in:
parent
53bb283fb3
commit
afb7fc2aab
@ -13,7 +13,6 @@
|
||||
const ColorPropType = require('ColorPropType');
|
||||
const Platform = require('Platform');
|
||||
const React = require('React');
|
||||
const PropTypes = require('prop-types');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
const Text = require('Text');
|
||||
const TouchableNativeFeedback = require('TouchableNativeFeedback');
|
||||
@ -22,6 +21,45 @@ const View = require('View');
|
||||
|
||||
const invariant = require('fbjs/lib/invariant');
|
||||
|
||||
import type {PressEvent} from 'CoreEventTypes';
|
||||
|
||||
type ButtonProps = $ReadOnly<{|
|
||||
/**
|
||||
* Text to display inside the button
|
||||
*/
|
||||
title: string,
|
||||
|
||||
/**
|
||||
* Handler to be called when the user taps the button
|
||||
*/
|
||||
onPress: (event?: PressEvent) => mixed,
|
||||
|
||||
/**
|
||||
* Color of the text (iOS), or background color of the button (Android)
|
||||
*/
|
||||
color?: ?string,
|
||||
|
||||
/**
|
||||
* TV preferred focus (see documentation for the View component).
|
||||
*/
|
||||
hasTVPreferredFocus?: ?boolean,
|
||||
|
||||
/**
|
||||
* Text to display for blindness accessibility features
|
||||
*/
|
||||
accessibilityLabel?: ?string,
|
||||
|
||||
/**
|
||||
* If true, disable all interactions for this component.
|
||||
*/
|
||||
disabled?: ?boolean,
|
||||
|
||||
/**
|
||||
* Used to locate this view in end-to-end tests.
|
||||
*/
|
||||
testID?: ?string,
|
||||
|}>;
|
||||
|
||||
/**
|
||||
* A basic button component that should render nicely on any platform. Supports
|
||||
* a minimal level of customization.
|
||||
@ -50,46 +88,7 @@ const invariant = require('fbjs/lib/invariant');
|
||||
*
|
||||
*/
|
||||
|
||||
class Button extends React.Component<{
|
||||
title: string,
|
||||
onPress: () => any,
|
||||
color?: ?string,
|
||||
hasTVPreferredFocus?: ?boolean,
|
||||
accessibilityLabel?: ?string,
|
||||
disabled?: ?boolean,
|
||||
testID?: ?string,
|
||||
}> {
|
||||
static propTypes = {
|
||||
/**
|
||||
* Text to display inside the button
|
||||
*/
|
||||
title: PropTypes.string.isRequired,
|
||||
/**
|
||||
* Text to display for blindness accessibility features
|
||||
*/
|
||||
accessibilityLabel: PropTypes.string,
|
||||
/**
|
||||
* Color of the text (iOS), or background color of the button (Android)
|
||||
*/
|
||||
color: ColorPropType,
|
||||
/**
|
||||
* If true, disable all interactions for this component.
|
||||
*/
|
||||
disabled: PropTypes.bool,
|
||||
/**
|
||||
* TV preferred focus (see documentation for the View component).
|
||||
*/
|
||||
hasTVPreferredFocus: PropTypes.bool,
|
||||
/**
|
||||
* Handler to be called when the user taps the button
|
||||
*/
|
||||
onPress: PropTypes.func.isRequired,
|
||||
/**
|
||||
* Used to locate this view in end-to-end tests.
|
||||
*/
|
||||
testID: PropTypes.string,
|
||||
};
|
||||
|
||||
class Button extends React.Component<ButtonProps> {
|
||||
render() {
|
||||
const {
|
||||
accessibilityLabel,
|
||||
|
Loading…
x
Reference in New Issue
Block a user