UNPKG

react-chousy

Version:

A simple React component for conditional rendering using JSX-friendly syntax.

20 lines (18 loc) 596 B
// src/components/SwitchCaseRender.tsx import { Fragment, jsx } from "react/jsx-runtime"; function SwitchCaseRender({ value, children }) { var _a, _b; return /* @__PURE__ */ jsx(Fragment, { children: (_b = (_a = children[value]) != null ? _a : children.default) != null ? _b : null }); } // src/index.tsx import { Fragment as Fragment2, jsx as jsx2 } from "react/jsx-runtime"; var ConditionalRender = ({ condition, children }) => { return /* @__PURE__ */ jsx2(Fragment2, { children: condition ? children.true : children.false }); }; export { ConditionalRender, SwitchCaseRender };