Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove deprecated defaultProps from function components #531

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/AnimatedModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface Props {
children: React.ReactNode
}

export const AnimatedModal = ({ children, visible }: Props) => {
export const AnimatedModal = ({ children, visible = false }: Props) => {
const translateY = new Animated.Value(height)

const showModal = Animated.timing(translateY, {
Expand Down Expand Up @@ -46,7 +46,3 @@ export const AnimatedModal = ({ children, visible }: Props) => {
</Animated.View>
)
}

AnimatedModal.defaultProps = {
visible: false,
}
11 changes: 4 additions & 7 deletions src/CountryFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const styles = StyleSheet.create({

export type CountryFilterProps = TextInputProps

export const CountryFilter = (props: CountryFilterProps) => {
export const CountryFilter = ({ autoFocus = false, placeholder= 'Enter country name', ...rest }: CountryFilterProps) => {
const {
filterPlaceholderTextColor,
fontFamily,
Expand All @@ -34,12 +34,9 @@ export const CountryFilter = (props: CountryFilterProps) => {
styles.input,
{ fontFamily, fontSize, color: onBackgroundTextColor },
]}
{...props}
autoFocus={autoFocus}
placeholder={placeholder}
{...rest}
/>
)
}

CountryFilter.defaultProps = {
autoFocus: false,
placeholder: 'Enter country name',
}
15 changes: 4 additions & 11 deletions src/CountryList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ const CountryItem = (props: CountryItemProps) => {
const {
country,
onSelect,
withFlag,
withFlag = true,
withEmoji,
withCallingCode,
withCallingCode = false,
withCurrency,
} = props
const extraContent: string[] = []
Expand Down Expand Up @@ -136,10 +136,7 @@ const CountryItem = (props: CountryItemProps) => {
</TouchableOpacity>
)
}
CountryItem.defaultProps = {
withFlag: true,
withCallingCode: false,
}

const MemoCountryItem = memo<CountryItemProps>(CountryItem)

const renderItem =
Expand Down Expand Up @@ -181,7 +178,7 @@ export const CountryList = (props: CountryListProps) => {
onSelect,
filter,
flatListProps,
filterFocus,
filterFocus = undefined,
} = props

const flatListRef = useRef<FlatList<Country>>(null)
Expand Down Expand Up @@ -256,7 +253,3 @@ export const CountryList = (props: CountryListProps) => {
</View>
)
}

CountryList.defaultProps = {
filterFocus: undefined,
}
13 changes: 4 additions & 9 deletions src/CountryModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ const styles = StyleSheet.create({

export const CountryModal = ({
children,
withModal,
disableNativeModal,
withModal = true,
disableNativeModal = false,
animationType = 'slide',
animated = true,
...props
}: ModalProps & {
children: React.ReactNode
Expand Down Expand Up @@ -44,10 +46,3 @@ export const CountryModal = ({
}
return content
}

CountryModal.defaultProps = {
animationType: 'slide',
animated: true,
withModal: true,
disableNativeModal: false,
}
18 changes: 5 additions & 13 deletions src/CountryPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ interface CountryPickerProps {

export const CountryPicker = (props: CountryPickerProps) => {
const {
allowFontScaling,
allowFontScaling = true,
countryCode,
region,
subregion,
Expand All @@ -107,11 +107,11 @@ export const CountryPicker = (props: CountryPickerProps) => {
withCallingCodeButton,
withCurrencyButton,
containerButtonStyle,
withAlphaFilter,
withCallingCode,
withAlphaFilter = false,
withCallingCode = false,
withCurrency,
withFlag,
withModal,
withModal = true,
disableNativeModal,
withFlagButton,
onClose: handleClose,
Expand All @@ -120,7 +120,7 @@ export const CountryPicker = (props: CountryPickerProps) => {
closeButtonStyle,
closeButtonImageStyle,
excludeCountries,
placeholder,
placeholder = 'Select Country',
preferredCountries,
} = props
const [state, setState] = useState<State>({
Expand Down Expand Up @@ -243,11 +243,3 @@ export const CountryPicker = (props: CountryPickerProps) => {
</>
)
}

CountryPicker.defaultProps = {
withModal: true,
withAlphaFilter: false,
withCallingCode: false,
placeholder: 'Select Country',
allowFontScaling: true,
}
9 changes: 2 additions & 7 deletions src/Flag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ const EmojiFlag = memo(({ countryCode, flagSize }: FlagType) => {

export const Flag = ({
countryCode,
withEmoji,
withFlagButton,
withEmoji = true,
withFlagButton = true,
flagSize,
}: FlagType) =>
withFlagButton ? (
Expand All @@ -92,8 +92,3 @@ export const Flag = ({
)}
</View>
) : null

Flag.defaultProps = {
withEmoji: true,
withFlagButton: true,
}
18 changes: 5 additions & 13 deletions src/FlagButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ export interface FlagButtonProps {

export const FlagButton = ({
allowFontScaling,
withEmoji,
withCountryNameButton,
withCallingCodeButton,
withCurrencyButton,
withFlagButton,
withEmoji = true,
withCountryNameButton = false,
withCallingCodeButton = false,
withCurrencyButton = false,
withFlagButton = true,
countryCode,
containerButtonStyle,
onOpen,
Expand Down Expand Up @@ -161,11 +161,3 @@ export const FlagButton = ({
</TouchableOpacity>
)
}

FlagButton.defaultProps = {
withEmoji: true,
withCountryNameButton: false,
withCallingCodeButton: false,
withCurrencyButton: false,
withFlagButton: true,
}
6 changes: 1 addition & 5 deletions src/HeaderModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface HeaderModalProps {
export const HeaderModal = (props: HeaderModalProps) => {
const {
withFilter,
withCloseButton,
withCloseButton = true,
closeButtonImage,
closeButtonStyle,
closeButtonImageStyle,
Expand All @@ -49,7 +49,3 @@ export const HeaderModal = (props: HeaderModalProps) => {
</View>
)
}

HeaderModal.defaultProps = {
withCloseButton: true,
}
7 changes: 1 addition & 6 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ interface Props {
onClose?(): void
}

const Main = ({ theme, translation, ...props }: Props) => {
const Main = ({ theme, translation, withEmoji = true, onSelect = () => {}, ...props }: Props) => {
return (
<ThemeProvider theme={{ ...DEFAULT_THEME, ...theme }}>
<CountryProvider value={{ ...DEFAULT_COUNTRY_CONTEXT, translation }}>
Expand All @@ -59,11 +59,6 @@ const Main = ({ theme, translation, ...props }: Props) => {
)
}

Main.defaultProps = {
onSelect: () => {},
withEmoji: true,
}

export default Main
export {
getCountriesAsync as getAllCountries,
Expand Down