From 2661c0d39879b5fd40ac787a7131ccc04de784d5 Mon Sep 17 00:00:00 2001 From: Pedro Guerreiro Date: Wed, 29 Nov 2023 16:35:04 +0000 Subject: [PATCH 1/2] refactor(typescript): migrate WalletSection --- .../{WalletSection.js => WalletSection.tsx} | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) rename src/components/{WalletSection.js => WalletSection.tsx} (63%) diff --git a/src/components/WalletSection.js b/src/components/WalletSection.tsx similarity index 63% rename from src/components/WalletSection.js rename to src/components/WalletSection.tsx index 1b5349098b82..9a1608597c32 100644 --- a/src/components/WalletSection.js +++ b/src/components/WalletSection.tsx @@ -1,29 +1,22 @@ -import PropTypes from 'prop-types'; -import React from 'react'; +import React, {ReactNode} from 'react'; import useThemeStyles from '@styles/useThemeStyles'; import Section from './Section'; -const propTypes = { +type WalletSectionProps = { /** Contents to display inside the section */ - children: PropTypes.node, + children?: ReactNode; /** The icon to display along with the title */ - icon: PropTypes.func, + icon?: (props: unknown) => React.ReactNode; /** The text to display in the subtitle of the section */ - subtitle: PropTypes.string, + subtitle?: string; /** The text to display in the title of the section */ - title: PropTypes.string.isRequired, + title: string; }; -const defaultProps = { - children: null, - icon: null, - subtitle: null, -}; - -function WalletSection({children, icon, subtitle, title}) { +function WalletSection({children, icon, subtitle, title}: WalletSectionProps) { const styles = useThemeStyles(); return (
Date: Fri, 1 Dec 2023 10:24:49 +0000 Subject: [PATCH 2/2] refactor: apply pull request feedback --- src/components/WalletSection.tsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/components/WalletSection.tsx b/src/components/WalletSection.tsx index 9a1608597c32..c0c02877828e 100644 --- a/src/components/WalletSection.tsx +++ b/src/components/WalletSection.tsx @@ -1,16 +1,15 @@ -import React, {ReactNode} from 'react'; +import React from 'react'; +import {SvgProps} from 'react-native-svg'; import useThemeStyles from '@styles/useThemeStyles'; +import ChildrenProps from '@src/types/utils/ChildrenProps'; import Section from './Section'; -type WalletSectionProps = { - /** Contents to display inside the section */ - children?: ReactNode; - +type WalletSectionProps = ChildrenProps & { /** The icon to display along with the title */ - icon?: (props: unknown) => React.ReactNode; + icon: React.FC; /** The text to display in the subtitle of the section */ - subtitle?: string; + subtitle: string; /** The text to display in the title of the section */ title: string;