From acdc2ce8f54bb834ee6bd5e97cce0db9380cda56 Mon Sep 17 00:00:00 2001 From: AlexAlexandre Date: Thu, 15 Jul 2021 18:46:31 -0300 Subject: [PATCH] [IMPROVE] fix some typing erros --- app/containers/ActionSheet/ActionSheet.tsx | 2 +- app/containers/ActionSheet/Provider.tsx | 23 +++++++++++----------- app/containers/ActivityIndicator.tsx | 6 ------ 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/app/containers/ActionSheet/ActionSheet.tsx b/app/containers/ActionSheet/ActionSheet.tsx index c465076c2..8551d5dbf 100644 --- a/app/containers/ActionSheet/ActionSheet.tsx +++ b/app/containers/ActionSheet/ActionSheet.tsx @@ -182,7 +182,7 @@ const ActionSheet = React.memo(forwardRef(({ children, theme }: {children: JSX.E styles.container, { backgroundColor: themes[theme].focusedBackground }, (isLandscape || isTablet) && styles.bottomSheet - ]} + ] as any} animationConfig={ANIMATION_CONFIG} // FlatList props data={data?.options} diff --git a/app/containers/ActionSheet/Provider.tsx b/app/containers/ActionSheet/Provider.tsx index de2a64ebf..c8715b613 100644 --- a/app/containers/ActionSheet/Provider.tsx +++ b/app/containers/ActionSheet/Provider.tsx @@ -1,10 +1,14 @@ -import React, { useRef, useContext, forwardRef } from 'react'; -import PropTypes from 'prop-types'; +import React, {useRef, useContext, forwardRef, ForwardedRef} from 'react'; import ActionSheet from './ActionSheet'; import { useTheme } from '../../theme'; -const context = React.createContext({ +interface IActionSheetProvider { + Provider: any; + Consumer: any; +} + +const context: IActionSheetProvider = React.createContext({ showActionSheet: () => {}, hideActionSheet: () => {} }); @@ -13,15 +17,15 @@ export const useActionSheet = () => useContext(context); const { Provider, Consumer } = context; -export const withActionSheet = (Component: any) => forwardRef((props, ref) => ( +export const withActionSheet = (Component: React.FC) => forwardRef((props: any, ref: ForwardedRef) => ( - {contexts => } + {(contexts: any) => } )); -export const ActionSheetProvider = React.memo(({ children }) => { - const ref: any = useRef(); - const { theme } = useTheme(); +export const ActionSheetProvider = React.memo(({ children }: {children: JSX.Element}) => { + const ref: ForwardedRef = useRef(); + const { theme }: any = useTheme(); const getContext = () => ({ showActionSheet: (options: any) => { @@ -40,6 +44,3 @@ export const ActionSheetProvider = React.memo(({ children }) => { ); }); -ActionSheetProvider.propTypes = { - children: PropTypes.node -}; diff --git a/app/containers/ActivityIndicator.tsx b/app/containers/ActivityIndicator.tsx index 3f21cac6a..50a60f0c3 100644 --- a/app/containers/ActivityIndicator.tsx +++ b/app/containers/ActivityIndicator.tsx @@ -32,10 +32,4 @@ const RCActivityIndicator = ({ theme = 'light', absolute, ...props }: IActivityI /> ); - -// TODO - test the app without the theme default -// RCActivityIndicator.defaultProps = { -// theme: 'light' -// }; - export default RCActivityIndicator;