@ducor/react
Version:
admin template ui interface
23 lines (22 loc) • 646 B
JavaScript
import { createElement, memo } from "react";
export function getGapClass(key) {
const gapList = {
0: "gap-0",
1: "gap-1",
2: "gap-2",
3: "gap-3",
4: "gap-4",
5: "gap-5",
6: "gap-6",
7: "gap-7",
8: "gap-8",
9: "gap-9",
10: "gap-10",
};
const index = typeof key === "number" ? Math.min(Math.max(key, 0), 10) : 0;
return gapList[index];
}
export function createMemoElement(type, props, children) {
const MemoizedComponent = memo((innerProps) => createElement(type, props, ...children));
return createElement(MemoizedComponent, props);
}