首页 > 其他分享 >前端项目实战壹佰柒拾叁react-admin+material ui-react-admin之Create之transform

前端项目实战壹佰柒拾叁react-admin+material ui-react-admin之Create之transform

时间:2023-08-21 11:36:05浏览次数:35  
标签:const admin material transform sanitizedData react key return data


我是歌谣 微信公众号关注前端小歌谣

export const UserCreate = (props) => {
    const transform = (data) => {
        const sanitizedData = {};
        for (const key in data) {
            if (typeof data[key] === "string" && data[key].length === 0) continue;
            sanitizedData[key] = data[key]; 
        }
        return sanitizedData;
    };
    return (
        <Create {...props} transform={transform}>
            ...
        </Create>
    );
}

运行结果

 文本输入的空值是空字符串,而不是null和undefined

标签:const,admin,material,transform,sanitizedData,react,key,return,data
From: https://blog.51cto.com/u_15460007/7173043

相关文章