Skip to content

Commit

Permalink
fix: change to use refPropTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
tienifr committed Aug 25, 2023
1 parent 97253b0 commit f0e98e3
Show file tree
Hide file tree
Showing 19 changed files with 37 additions and 35 deletions.
2 changes: 1 addition & 1 deletion ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1311,4 +1311,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 845537d35601574adcd0794e17003ba7dbccdbfd

COCOAPODS: 1.12.1
COCOAPODS: 1.11.3
4 changes: 2 additions & 2 deletions src/components/AmountTextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import PropTypes from 'prop-types';
import TextInput from './TextInput';
import styles from '../styles/styles';
import CONST from '../CONST';
import refPropTypes from './refPropTypes';

const propTypes = {
/** Formatted amount in local currency */
formattedAmount: PropTypes.string.isRequired,

/** A ref to forward to amount text input */
// eslint-disable-next-line react/forbid-prop-types
forwardedRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({current: PropTypes.object})]),
forwardedRef: refPropTypes,

/** Function to call when amount in text input is changed */
onChangeAmount: PropTypes.func.isRequired,
Expand Down
3 changes: 2 additions & 1 deletion src/components/Attachments/AttachmentCarousel/Pager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import PagerView from 'react-native-pager-view';
import _ from 'underscore';
import styles from '../../../../styles/styles';
import AttachmentCarouselPagerContext from './AttachmentCarouselPagerContext';
import refPropTypes from '../../../refPropTypes';

const AnimatedPagerView = Animated.createAnimatedComponent(createNativeWrapper(PagerView));

Expand Down Expand Up @@ -50,7 +51,7 @@ const pagerPropTypes = {
onSwipeSuccess: PropTypes.func,
onSwipeDown: PropTypes.func,
onPinchGestureChange: PropTypes.func,
forwardedRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
forwardedRef: refPropTypes,
containerWidth: PropTypes.number.isRequired,
containerHeight: PropTypes.number.isRequired,
};
Expand Down
4 changes: 2 additions & 2 deletions src/components/Button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import * as Expensicons from '../Icon/Expensicons';
import withNavigationFocus from '../withNavigationFocus';
import validateSubmitShortcut from './validateSubmitShortcut';
import PressableWithFeedback from '../Pressable/PressableWithFeedback';
import refPropTypes from '../refPropTypes';

const propTypes = {
/** The text for the button label */
Expand Down Expand Up @@ -118,8 +119,7 @@ const propTypes = {
accessibilityLabel: PropTypes.string,

/** A ref to forward the button */
// eslint-disable-next-line react/forbid-prop-types
forwardedRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({current: PropTypes.object})]),
forwardedRef: refPropTypes,
};

const defaultProps = {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as Expensicons from './Icon/Expensicons';
import * as StyleUtils from '../styles/StyleUtils';
import CONST from '../CONST';
import PressableWithFeedback from './Pressable/PressableWithFeedback';
import refPropTypes from './refPropTypes';

const propTypes = {
/** Whether checkbox is checked */
Expand Down Expand Up @@ -45,8 +46,7 @@ const propTypes = {
caretSize: PropTypes.number,

/** A ref to forward to the Pressable */
// eslint-disable-next-line react/forbid-prop-types
forwardedRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({current: PropTypes.object})]),
forwardedRef: refPropTypes,

/** An accessibility label for the checkbox */
accessibilityLabel: PropTypes.string.isRequired,
Expand Down
4 changes: 2 additions & 2 deletions src/components/CountryPicker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import MenuItemWithTopDescription from '../MenuItemWithTopDescription';
import useLocalize from '../../hooks/useLocalize';
import CountrySelectorModal from './CountrySelectorModal';
import FormHelpMessage from '../FormHelpMessage';
import refPropTypes from '../refPropTypes';

const propTypes = {
/** Form Error description */
Expand All @@ -19,8 +20,7 @@ const propTypes = {
onInputChange: PropTypes.func,

/** A ref to forward to MenuItemWithTopDescription */
// eslint-disable-next-line react/forbid-prop-types
forwardedRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({current: PropTypes.object})]),
forwardedRef: refPropTypes,
};

const defaultProps = {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Picker/BasePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import Text from '../Text';
import styles from '../../styles/styles';
import themeColors from '../../styles/themes/default';
import {ScrollContext} from '../ScrollViewWithContext';
import refPropTypes from '../refPropTypes';

const propTypes = {
/** A forwarded ref */
// eslint-disable-next-line react/forbid-prop-types
forwardedRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({current: PropTypes.object})]),
forwardedRef: refPropTypes,

/** BasePicker label */
label: PropTypes.string,
Expand Down
4 changes: 2 additions & 2 deletions src/components/StatePicker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import MenuItemWithTopDescription from '../MenuItemWithTopDescription';
import useLocalize from '../../hooks/useLocalize';
import FormHelpMessage from '../FormHelpMessage';
import StateSelectorModal from './StateSelectorModal';
import refPropTypes from '../refPropTypes';

const propTypes = {
/** Error text to display */
Expand All @@ -19,8 +20,7 @@ const propTypes = {
onInputChange: PropTypes.func,

/** A ref to forward to MenuItemWithTopDescription */
// eslint-disable-next-line react/forbid-prop-types
forwardedRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({current: PropTypes.object})]),
forwardedRef: refPropTypes,

/** Label to display on field */
label: PropTypes.string,
Expand Down
4 changes: 2 additions & 2 deletions src/components/TextInputWithCurrencySymbol.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import CurrencySymbolButton from './CurrencySymbolButton';
import * as CurrencyUtils from '../libs/CurrencyUtils';
import useLocalize from '../hooks/useLocalize';
import * as MoneyRequestUtils from '../libs/MoneyRequestUtils';
import refPropTypes from './refPropTypes';

const propTypes = {
/** A ref to forward to amount text input */
// eslint-disable-next-line react/forbid-prop-types
forwardedRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({current: PropTypes.object})]),
forwardedRef: refPropTypes,

/** Formatted amount in local currency */
formattedAmount: PropTypes.string.isRequired,
Expand Down
4 changes: 2 additions & 2 deletions src/components/TextLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import styles from '../styles/styles';
import stylePropTypes from '../styles/stylePropTypes';
import CONST from '../CONST';
import * as Link from '../libs/actions/Link';
import refPropTypes from './refPropTypes';

const propTypes = {
/** Link to open in new tab */
Expand All @@ -24,8 +25,7 @@ const propTypes = {
onMouseDown: PropTypes.func,

/** A ref to forward to text */
// eslint-disable-next-line react/forbid-prop-types
forwardedRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({current: PropTypes.object})]),
forwardedRef: refPropTypes,
};

const defaultProps = {
Expand Down
3 changes: 2 additions & 1 deletion src/components/menuItemPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import _ from 'underscore';
import CONST from '../CONST';
import stylePropTypes from '../styles/stylePropTypes';
import avatarPropTypes from './avatarPropTypes';
import refPropTypes from './refPropTypes';

const propTypes = {
/** Text to be shown as badge near the right end. */
Expand Down Expand Up @@ -118,7 +119,7 @@ const propTypes = {
shouldBlockSelection: PropTypes.bool,

/** The ref to the menu item */
forwardedRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
forwardedRef: refPropTypes,

/** Any adjustments to style when menu item is hovered or pressed */
hoverAndPressStyle: PropTypes.arrayOf(PropTypes.object),
Expand Down
4 changes: 2 additions & 2 deletions src/components/withAnimatedRef.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import {useAnimatedRef} from 'react-native-reanimated';
import PropTypes from 'prop-types';
import getComponentDisplayName from '../libs/getComponentDisplayName';
import refPropTypes from './refPropTypes';

export default function withAnimatedRef(WrappedComponent) {
function WithAnimatedRef(props) {
Expand All @@ -17,8 +18,7 @@ export default function withAnimatedRef(WrappedComponent) {
}
WithAnimatedRef.displayName = `withAnimatedRef(${getComponentDisplayName(WrappedComponent)})`;
WithAnimatedRef.propTypes = {
// eslint-disable-next-line react/forbid-prop-types
forwardedRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({current: PropTypes.object})]),
forwardedRef: refPropTypes,
};
WithAnimatedRef.defaultProps = {
forwardedRef: undefined,
Expand Down
4 changes: 2 additions & 2 deletions src/components/withCurrentUserPersonalDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {withOnyx} from 'react-native-onyx';
import getComponentDisplayName from '../libs/getComponentDisplayName';
import ONYXKEYS from '../ONYXKEYS';
import personalDetailsPropType from '../pages/personalDetailsPropType';
import refPropTypes from './refPropTypes';

const withCurrentUserPersonalDetailsPropTypes = {
currentUserPersonalDetails: personalDetailsPropType,
Expand All @@ -15,8 +16,7 @@ const withCurrentUserPersonalDetailsDefaultProps = {

export default function (WrappedComponent) {
const propTypes = {
// eslint-disable-next-line react/forbid-prop-types
forwardedRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({current: PropTypes.object})]),
forwardedRef: refPropTypes,

/** Personal details of all the users, including current user */
personalDetails: PropTypes.objectOf(personalDetailsPropType),
Expand Down
4 changes: 2 additions & 2 deletions src/components/withNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import {useNavigation} from '@react-navigation/native';
import getComponentDisplayName from '../libs/getComponentDisplayName';
import refPropTypes from './refPropTypes';

const withNavigationPropTypes = {
navigation: PropTypes.object.isRequired,
Expand All @@ -22,8 +23,7 @@ export default function withNavigation(WrappedComponent) {

WithNavigation.displayName = `withNavigation(${getComponentDisplayName(WrappedComponent)})`;
WithNavigation.propTypes = {
// eslint-disable-next-line react/forbid-prop-types
forwardedRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({current: PropTypes.object})]),
forwardedRef: refPropTypes,
};
WithNavigation.defaultProps = {
forwardedRef: () => {},
Expand Down
4 changes: 2 additions & 2 deletions src/components/withNavigationFallback.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, {Component} from 'react';
import PropTypes from 'prop-types';
import {NavigationContext} from '@react-navigation/core';
import getComponentDisplayName from '../libs/getComponentDisplayName';
import refPropTypes from './refPropTypes';

export default function (WrappedComponent) {
class WithNavigationFallback extends Component {
Expand Down Expand Up @@ -36,8 +37,7 @@ export default function (WrappedComponent) {
WithNavigationFallback.contextType = NavigationContext;
WithNavigationFallback.displayName = `WithNavigationFocusWithFallback(${getComponentDisplayName(WrappedComponent)})`;
WithNavigationFallback.propTypes = {
// eslint-disable-next-line react/forbid-prop-types
forwardedRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({current: PropTypes.object})]),
forwardedRef: refPropTypes,
};
WithNavigationFallback.defaultProps = {
forwardedRef: undefined,
Expand Down
4 changes: 2 additions & 2 deletions src/components/withNavigationFocus.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import {useIsFocused} from '@react-navigation/native';
import getComponentDisplayName from '../libs/getComponentDisplayName';
import refPropTypes from './refPropTypes';

const withNavigationFocusPropTypes = {
isFocused: PropTypes.bool.isRequired,
Expand All @@ -22,8 +23,7 @@ export default function withNavigationFocus(WrappedComponent) {

WithNavigationFocus.displayName = `withNavigationFocus(${getComponentDisplayName(WrappedComponent)})`;
WithNavigationFocus.propTypes = {
// eslint-disable-next-line react/forbid-prop-types
forwardedRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({current: PropTypes.object})]),
forwardedRef: refPropTypes,
};
WithNavigationFocus.defaultProps = {
forwardedRef: undefined,
Expand Down
4 changes: 2 additions & 2 deletions src/components/withToggleVisibilityView.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {View} from 'react-native';
import PropTypes from 'prop-types';
import styles from '../styles/styles';
import getComponentDisplayName from '../libs/getComponentDisplayName';
import refPropTypes from './refPropTypes';

const toggleVisibilityViewPropTypes = {
/** Whether the content is visible. */
Expand All @@ -25,8 +26,7 @@ export default function (WrappedComponent) {

WithToggleVisibilityView.displayName = `WithToggleVisibilityView(${getComponentDisplayName(WrappedComponent)})`;
WithToggleVisibilityView.propTypes = {
// eslint-disable-next-line react/forbid-prop-types
forwardedRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({current: PropTypes.object})]),
forwardedRef: refPropTypes,

/** Whether the content is visible. */
isVisible: PropTypes.bool,
Expand Down
4 changes: 2 additions & 2 deletions src/components/withViewportOffsetTop.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import lodashGet from 'lodash/get';
import getComponentDisplayName from '../libs/getComponentDisplayName';
import addViewportResizeListener from '../libs/VisualViewport';
import refPropTypes from './refPropTypes';

const viewportOffsetTopPropTypes = {
// viewportOffsetTop returns the offset of the top edge of the visual viewport from the
Expand Down Expand Up @@ -53,8 +54,7 @@ export default function (WrappedComponent) {

WithViewportOffsetTop.displayName = `WithViewportOffsetTop(${getComponentDisplayName(WrappedComponent)})`;
WithViewportOffsetTop.propTypes = {
// eslint-disable-next-line react/forbid-prop-types
forwardedRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({current: PropTypes.any})]),
forwardedRef: refPropTypes,
};
WithViewportOffsetTop.defaultProps = {
forwardedRef: undefined,
Expand Down
4 changes: 2 additions & 2 deletions src/pages/iou/steps/MoneyRequestAmountForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import * as DeviceCapabilities from '../../../libs/DeviceCapabilities';
import TextInputWithCurrencySymbol from '../../../components/TextInputWithCurrencySymbol';
import useLocalize from '../../../hooks/useLocalize';
import CONST from '../../../CONST';
import refPropTypes from '../../../components/refPropTypes';

const propTypes = {
/** IOU amount saved in Onyx */
Expand All @@ -24,8 +25,7 @@ const propTypes = {
isEditing: PropTypes.bool,

/** Refs forwarded to the TextInputWithCurrencySymbol */
// eslint-disable-next-line react/forbid-prop-types
forwardedRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({current: PropTypes.object})]),
forwardedRef: refPropTypes,

/** Fired when back button pressed, navigates to currency selection page */
onCurrencyButtonPress: PropTypes.func.isRequired,
Expand Down

0 comments on commit f0e98e3

Please sign in to comment.