import { useEffect , useRef } from 'react' ; import type { ProFormProps } from '@ant-design/pro-form' ; interface IProps extends ProFormProps { onInitialValues ( values ) : object ; [ name ] : any ; } param props export default function useGeekProForm ( props ) { const form = useRef < any > ( { } ) ; useEffect ( ( ) => { if ( props ?. visible && props . selectedData ) { if ( props . isEdit ) { let selectedData = props . selectedData ; if ( props . onInitialValues ) { selectedData = props . onInitialValues ( props . selectedData ) ; } console . log ( 'form.current.setFieldsValue:' , selectedData ) ; form . current . setFieldsValue ( selectedData ) ; } else { form . current . resetFields ( ) ; } } } , [ props ?. visible ] ) ; return { formRef : form , ... props } ; }