From bf7473c39b20dfdc0e6712f519522f1bccba4aea Mon Sep 17 00:00:00 2001 From: Gleidson Daniel Silva Date: Wed, 6 Jul 2022 16:57:00 -0300 Subject: [PATCH] [FIX] Add hoistNonReactStatics to withActionSheet hoc (#4331) --- app/containers/ActionSheet/Provider.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/containers/ActionSheet/Provider.tsx b/app/containers/ActionSheet/Provider.tsx index e2b37dad9..e28d49c22 100644 --- a/app/containers/ActionSheet/Provider.tsx +++ b/app/containers/ActionSheet/Provider.tsx @@ -1,7 +1,8 @@ +import hoistNonReactStatics from 'hoist-non-react-statics'; import React, { ForwardedRef, forwardRef, useContext, useRef } from 'react'; -import ActionSheet from './ActionSheet'; import { TIconsName } from '../CustomIcon'; +import ActionSheet from './ActionSheet'; export type TActionSheetOptionsItem = { title: string; @@ -35,11 +36,15 @@ export const useActionSheet = () => useContext(context); const { Provider, Consumer } = context; -export const withActionSheet = (Component: React.ComponentType): typeof Component => - forwardRef((props: typeof React.Component, ref: ForwardedRef) => ( +export const withActionSheet = (Component: React.ComponentType): typeof Component => { + const WithActionSheetComponent = forwardRef((props: typeof React.Component, ref: ForwardedRef) => ( {(contexts: IActionSheetProvider) => } )); + hoistNonReactStatics(WithActionSheetComponent, Component); + return WithActionSheetComponent; +}; + export const ActionSheetProvider = React.memo(({ children }: { children: React.ReactElement | React.ReactElement[] }) => { const ref: ForwardedRef = useRef(null);