import { useMemo } from 'react' ; export default function useMergeProps < PropsType > ( componentProps , defaultProps ) { const props = useMemo ( ( ) => { const mProps = { ... componentProps } ; for ( const propName in defaultProps ) { if ( mProps [ propName ] === undefined ) { mProps [ propName ] = defaultProps [ propName ] ; } } return mProps ; } , [ componentProps , defaultProps ] ) ; return props ; }