UNPKG

oneframe-react

Version:

Oneframe React ## Components, Hooks, Helper Functions & State Management

28 lines (27 loc) 1.27 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const react_1 = __importDefault(require("react")); const lodash_1 = require("lodash"); const withTable_1 = require("./withTable"); const prop_types_1 = __importDefault(require("prop-types")); const Cell = (props) => { const { onClick, width, className, children } = props; const handleClick = () => { onClick && onClick(); }; return (react_1.default.createElement("div", { className: `custom-table-cell ${className}`, onClick: handleClick, style: { width: width, flexShrink: width ? 0 : 1, } }, children)); }; Cell.propTypes = { width: prop_types_1.default.oneOfType([prop_types_1.default.number, prop_types_1.default.string]), children: prop_types_1.default.any, className: prop_types_1.default.string, onClick: prop_types_1.default.func, }; const MemoComponent = react_1.default.memo(Cell, (p, n) => lodash_1.isEqual(p.children, n.children) && lodash_1.isEqual(p.width, n.width) && lodash_1.isEqual(p.className, n.className)); exports.default = withTable_1.withTable(MemoComponent);