Closed johnoppenheimer closed 4 years ago
I just came here from changelog. It is possible to use props from a component without component needing to export its interface. This is how I use it:
import ModalLib from 'react-responsive-modal';
type ModalLibProps = React.ComponentProps<typeof ModalLib>;
interface Props {
open: ModalLibProps['open'];
onClose: ModalLibProps['onClose'];
children: React.ReactNode;
showCloseIcon?: ModalLibProps['showCloseIcon'];
closeOnEsc?: ModalLibProps['closeOnEsc'];
closeOnOverlayClick?: ModalLibProps['closeOnOverlayClick'];
}
Having the ModalProps exported might be useful for creating parent component that still comply with the props, without having to rewrite type for those.