Skip to content

Commit

Permalink
added displayName to ref forwarded components
Browse files Browse the repository at this point in the history
  • Loading branch information
ikevin127 committed Oct 24, 2023
1 parent 17ea722 commit 49bc03b
Show file tree
Hide file tree
Showing 84 changed files with 534 additions and 236 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ module.exports = {
},
],
curly: 'error',
"react/display-name": 'error',
},
},
{
Expand Down
7 changes: 6 additions & 1 deletion __mocks__/react-native-safe-area-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,18 @@ function withSafeAreaInsets(WrappedComponent) {
/>
);
}
return forwardRef((props, ref) => (

const WithSafeAreaInsetsWithRef = forwardRef((props, ref) => (
<WithSafeAreaInsets
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
forwardedRef={ref}
/>
));

WithSafeAreaInsetsWithRef.displayName = 'WithSafeAreaInsetsWithRef';

return WithSafeAreaInsetsWithRef;
}

const SafeAreaView = View;
Expand Down
20 changes: 11 additions & 9 deletions src/components/AddressSearch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -499,15 +499,17 @@ AddressSearch.propTypes = propTypes;
AddressSearch.defaultProps = defaultProps;
AddressSearch.displayName = 'AddressSearch';

const AddressSearchWithRef = React.forwardRef((props, ref) => (
<AddressSearch
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
innerRef={ref}
/>
));

AddressSearchWithRef.displayName = 'AddressSearchWithRef';

export default compose(
withNetwork(),
withLocalize,
)(
React.forwardRef((props, ref) => (
<AddressSearch
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
innerRef={ref}
/>
)),
);
)(AddressSearchWithRef);
6 changes: 5 additions & 1 deletion src/components/AmountTextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,14 @@ AmountTextInput.propTypes = propTypes;
AmountTextInput.defaultProps = defaultProps;
AmountTextInput.displayName = 'AmountTextInput';

export default React.forwardRef((props, ref) => (
const AmountTextInputWithRef = React.forwardRef((props, ref) => (
<AmountTextInput
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
forwardedRef={ref}
/>
));

AmountTextInputWithRef.displayName = 'AmountTextInputWithRef';

export default AmountTextInputWithRef;
6 changes: 5 additions & 1 deletion src/components/Attachments/AttachmentCarousel/Pager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,14 @@ function AttachmentCarouselPager({
AttachmentCarouselPager.propTypes = pagerPropTypes;
AttachmentCarouselPager.defaultProps = pagerDefaultProps;

export default React.forwardRef((props, ref) => (
const AttachmentCarouselPagerWithRef = React.forwardRef((props, ref) => (
<AttachmentCarouselPager
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
forwardedRef={ref}
/>
));

AttachmentCarouselPagerWithRef.displayName = 'AttachmentCarouselPagerWithRef';

export default AttachmentCarouselPagerWithRef;
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,14 @@ function BaseAutoCompleteSuggestions(props) {
BaseAutoCompleteSuggestions.propTypes = propTypes;
BaseAutoCompleteSuggestions.displayName = 'BaseAutoCompleteSuggestions';

export default React.forwardRef((props, ref) => (
const BaseAutoCompleteSuggestionsWithRef = React.forwardRef((props, ref) => (
<BaseAutoCompleteSuggestions
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
forwardedRef={ref}
/>
));

BaseAutoCompleteSuggestionsWithRef.displayName = 'BaseAutoCompleteSuggestionsWithRef';

export default BaseAutoCompleteSuggestionsWithRef;
6 changes: 5 additions & 1 deletion src/components/BaseMiniContextMenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,14 @@ BaseMiniContextMenuItem.propTypes = propTypes;
BaseMiniContextMenuItem.defaultProps = defaultProps;
BaseMiniContextMenuItem.displayName = 'BaseMiniContextMenuItem';

export default React.forwardRef((props, ref) => (
const BaseMiniContextMenuItemWithRef = React.forwardRef((props, ref) => (
<BaseMiniContextMenuItem
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
innerRef={ref}
/>
));

BaseMiniContextMenuItemWithRef.displayName = 'BaseMiniContextMenuItemWithRef';

export default BaseMiniContextMenuItemWithRef;
6 changes: 5 additions & 1 deletion src/components/CheckboxWithLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,14 @@ CheckboxWithLabel.propTypes = propTypes;
CheckboxWithLabel.defaultProps = defaultProps;
CheckboxWithLabel.displayName = 'CheckboxWithLabel';

export default React.forwardRef((props, ref) => (
const CheckboxWithLabelWithRef = React.forwardRef((props, ref) => (
<CheckboxWithLabel
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
forwardedRef={ref}
/>
));

CheckboxWithLabelWithRef.displayName = 'CheckboxWithLabelWithRef';

export default CheckboxWithLabelWithRef;
6 changes: 5 additions & 1 deletion src/components/Composer/index.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,14 @@ function Composer({shouldClear, onClear, isDisabled, maxLines, forwardedRef, isC
Composer.propTypes = propTypes;
Composer.defaultProps = defaultProps;

export default React.forwardRef((props, ref) => (
const ComposerWithRef = React.forwardRef((props, ref) => (
<Composer
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
forwardedRef={ref}
/>
));

ComposerWithRef.displayName = 'ComposerWithRef';

export default ComposerWithRef;
6 changes: 5 additions & 1 deletion src/components/Composer/index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,14 @@ function Composer({shouldClear, onClear, isDisabled, maxLines, forwardedRef, isC
Composer.propTypes = propTypes;
Composer.defaultProps = defaultProps;

export default React.forwardRef((props, ref) => (
const ComposerWithRef = React.forwardRef((props, ref) => (
<Composer
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
forwardedRef={ref}
/>
));

ComposerWithRef.displayName = 'ComposerWithRef';

export default ComposerWithRef;
20 changes: 11 additions & 9 deletions src/components/Composer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,16 +489,18 @@ function Composer({
Composer.propTypes = propTypes;
Composer.defaultProps = defaultProps;

const ComposerWithRef = React.forwardRef((props, ref) => (
<Composer
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
forwardedRef={ref}
/>
));

ComposerWithRef.displayName = 'ComposerWithRef';

export default compose(
withLocalize,
withWindowDimensions,
withNavigation,
)(
React.forwardRef((props, ref) => (
<Composer
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
forwardedRef={ref}
/>
)),
);
)(ComposerWithRef);
6 changes: 5 additions & 1 deletion src/components/ContextMenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,14 @@ ContextMenuItem.propTypes = propTypes;
ContextMenuItem.defaultProps = defaultProps;
ContextMenuItem.displayName = 'ContextMenuItem';

export default forwardRef((props, ref) => (
const ContextMenuItemWithRef = forwardRef((props, ref) => (
<ContextMenuItem
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
innerRef={ref}
/>
));

ContextMenuItemWithRef.displayName = 'ContextMenuItemWithRef';

export default ContextMenuItemWithRef;
6 changes: 5 additions & 1 deletion src/components/CountrySelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,14 @@ CountrySelector.propTypes = propTypes;
CountrySelector.defaultProps = defaultProps;
CountrySelector.displayName = 'CountrySelector';

export default React.forwardRef((props, ref) => (
const CountrySelectorWithRef = React.forwardRef((props, ref) => (
<CountrySelector
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
forwardedRef={ref}
/>
));

CountrySelectorWithRef.displayName = 'CountrySelectorWithRef';

export default CountrySelectorWithRef;
6 changes: 5 additions & 1 deletion src/components/DatePicker/index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,14 @@ DatePicker.displayName = 'DatePicker';
* locale. Otherwise the spinner would be present in the system locale and it would be weird if it happens
* that the modal buttons are in one locale (app) while the (spinner) month names are another (system)
*/
export default React.forwardRef((props, ref) => (
const DatePickerWithRef = React.forwardRef((props, ref) => (
<DatePicker
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
innerRef={ref}
/>
));

DatePickerWithRef.displayName = 'DatePickerWithRef';

export default DatePickerWithRef;
6 changes: 5 additions & 1 deletion src/components/DatePicker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,14 @@ DatePicker.displayName = 'DatePicker';
DatePicker.propTypes = propTypes;
DatePicker.defaultProps = defaultProps;

export default React.forwardRef((props, ref) => (
const DatePickerWithRef = React.forwardRef((props, ref) => (
<DatePicker
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
innerRef={ref}
/>
));

DatePickerWithRef.displayName = 'DatePickerWithRef';

export default DatePickerWithRef;
21 changes: 12 additions & 9 deletions src/components/EmojiPicker/EmojiPickerButtonDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,15 @@ function EmojiPickerButtonDropdown(props) {
EmojiPickerButtonDropdown.propTypes = propTypes;
EmojiPickerButtonDropdown.defaultProps = defaultProps;
EmojiPickerButtonDropdown.displayName = 'EmojiPickerButtonDropdown';
export default withLocalize(
React.forwardRef((props, ref) => (
<EmojiPickerButtonDropdown
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
forwardedRef={ref}
/>
)),
);

const EmojiPickerButtonDropdownWithRef = React.forwardRef((props, ref) => (
<EmojiPickerButtonDropdown
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
forwardedRef={ref}
/>
));

EmojiPickerButtonDropdownWithRef.displayName = 'EmojiPickerButtonDropdownWithRef';

export default withLocalize(EmojiPickerButtonDropdownWithRef);
20 changes: 11 additions & 9 deletions src/components/EmojiPicker/EmojiPickerMenu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,16 @@ function EmojiPickerMenu(props) {
EmojiPickerMenu.propTypes = propTypes;
EmojiPickerMenu.defaultProps = defaultProps;

const EmojiPickerMenuWithRef = React.forwardRef((props, ref) => (
<EmojiPickerMenu
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
forwardedRef={ref}
/>
));

EmojiPickerMenuWithRef.displayName = 'EmojiPickerMenuWithRef';

export default compose(
withLocalize,
withOnyx({
Expand All @@ -536,12 +546,4 @@ export default compose(
key: ONYXKEYS.FREQUENTLY_USED_EMOJIS,
},
}),
)(
React.forwardRef((props, ref) => (
<EmojiPickerMenu
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
forwardedRef={ref}
/>
)),
);
)(EmojiPickerMenuWithRef);
20 changes: 11 additions & 9 deletions src/components/EmojiPicker/EmojiPickerMenu/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,16 @@ EmojiPickerMenu.displayName = 'EmojiPickerMenu';
EmojiPickerMenu.propTypes = propTypes;
EmojiPickerMenu.defaultProps = defaultProps;

const EmojiPickerMenuWithRef = React.forwardRef((props, ref) => (
<EmojiPickerMenu
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
forwardedRef={ref}
/>
));

EmojiPickerMenuWithRef.displayName = 'EmojiPickerMenuWithRef';

export default compose(
withLocalize,
withOnyx({
Expand All @@ -211,12 +221,4 @@ export default compose(
key: ONYXKEYS.FREQUENTLY_USED_EMOJIS,
},
}),
)(
React.forwardRef((props, ref) => (
<EmojiPickerMenu
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
forwardedRef={ref}
/>
)),
);
)(EmojiPickerMenuWithRef);
6 changes: 5 additions & 1 deletion src/components/FlatList/index.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,14 @@ function CustomFlatList(props) {
CustomFlatList.propTypes = propTypes;
CustomFlatList.defaultProps = defaultProps;

export default forwardRef((props, ref) => (
const CustomFlatListWithRef = forwardRef((props, ref) => (
<CustomFlatList
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
innerRef={ref}
/>
));

CustomFlatListWithRef.displayName = 'CustomFlatListWithRef';

export default CustomFlatListWithRef;
6 changes: 5 additions & 1 deletion src/components/FloatingActionButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,14 @@ FloatingActionButton.defaultProps = defaultProps;

const FloatingActionButtonWithLocalize = withLocalize(FloatingActionButton);

export default React.forwardRef((props, ref) => (
const FloatingActionButtonWithLocalizeWithRef = React.forwardRef((props, ref) => (
<FloatingActionButtonWithLocalize
// eslint-disable-next-line
{...props}
buttonRef={ref}
/>
));

FloatingActionButtonWithLocalizeWithRef.displayName = 'FloatingActionButtonWithLocalizeWithRef';

export default FloatingActionButtonWithLocalizeWithRef;
6 changes: 5 additions & 1 deletion src/components/Form/InputWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ InputWrapper.propTypes = propTypes;
InputWrapper.defaultProps = defaultProps;
InputWrapper.displayName = 'InputWrapper';

export default forwardRef((props, ref) => (
const InputWrapperWithRef = forwardRef((props, ref) => (
<InputWrapper
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
forwardedRef={ref}
/>
));

InputWrapperWithRef.displayName = 'InputWrapperWithRef';

export default InputWrapperWithRef;
Loading

0 comments on commit 49bc03b

Please sign in to comment.