场景
有很多表单元素且disabled都受父组件统一控制。此时可以统一包一层FormItemChildrenDisabledHandler
function FormItemChildrenDisabledHandler(props:{disabled: boolean, children: React.ReactNode}) {
React.Children.forEach(props.children, child=>{
if(child?.type?.displayName === 'FormItem'){
const childProps = child?.props?.children?.props ?? {}
if('disabled' in childProps){
child?.props?.children?.props?.disabled = props.disabled
}
}
})
return <>{props.children}</>
}