UNPKG

@schema-render/form-render-react

Version:

Out-of-the-box form rendering library based on Core and Antd.

21 lines (20 loc) 645 B
import { useMemo } from "react"; import Horizontal from "../itemLayouts/Horizontal"; import Vertical from "../itemLayouts/Vertical"; export default function useItemLayout({ itemLayout }) { // 表单项布局结构处理 const ItemLayout = useMemo(()=>{ // 没有 itemLayout 或者声明垂直布局时,使用垂直布局 if (!itemLayout || itemLayout === 'horizontal') { return Horizontal; } if (itemLayout === 'vertical') { return Vertical; } // 自定义 itemLayout 布局 return itemLayout; }, [ itemLayout ]); return ItemLayout; }