import React, { useRef, useContext, forwardRef } from 'react'; import PropTypes from 'prop-types'; import ActionSheet from './ActionSheet'; import { useTheme } from '../../theme'; const context = React.createContext({ showActionSheet: () => {}, hideActionSheet: () => {} }); export const useActionSheet = () => useContext(context); const { Provider, Consumer } = context; export const withActionSheet = (Component: any) => forwardRef((props, ref) => ( {contexts => } )); export const ActionSheetProvider = React.memo(({ children }) => { const ref: any = useRef(); const { theme } = useTheme(); const getContext = () => ({ showActionSheet: (options: any) => { ref.current?.showActionSheet(options); }, hideActionSheet: () => { ref.current?.hideActionSheet(); } }); return ( {children} ); }); ActionSheetProvider.propTypes = { children: PropTypes.node };