Skip to content

Commit

Permalink
refactor(typescript): apply pull request feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
pac-guerreiro committed Jan 16, 2024
1 parent 6c24926 commit 7b15836
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions src/components/CountrySelector.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, {type ForwardedRef, useEffect} from 'react';
import React, {forwardRef, useEffect} from 'react';
import type {ForwardedRef} from 'react';
import {View} from 'react-native';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
Expand All @@ -23,11 +24,7 @@ type CountrySelectorProps = {
inputID: string;
};

type CountrySelectorPropsWithForwardedRef = CountrySelectorProps & {
forwardedRef: ForwardedRef<View>;
};

function CountrySelector({errorText = '', value: countryCode, onInputChange, forwardedRef = () => {}}: CountrySelectorPropsWithForwardedRef) {
function CountrySelector({errorText = '', value: countryCode, onInputChange}: CountrySelectorProps, ref: ForwardedRef<View>) {
const styles = useThemeStyles();
const {translate} = useLocalize();

Expand All @@ -45,7 +42,7 @@ function CountrySelector({errorText = '', value: countryCode, onInputChange, for
<MenuItemWithTopDescription
shouldShowRightIcon
title={title}
ref={forwardedRef}
ref={ref}
descriptionTextStyle={countryTitleDescStyle}
description={translate('common.country')}
onPress={() => {
Expand All @@ -62,12 +59,4 @@ function CountrySelector({errorText = '', value: countryCode, onInputChange, for

CountrySelector.displayName = 'CountrySelector';

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

export default CountrySelectorWithRef;
export default forwardRef(CountrySelector);

0 comments on commit 7b15836

Please sign in to comment.