UNPKG

react-generate-comp

Version:

Generate React components in current execute directory by typing with CLI.

28 lines (27 loc) 1.02 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.useStateGen = void 0; const clipboardy_1 = __importDefault(require("clipboardy")); const bigSmallLetter_1 = require("./supportGen/bigSmallLetter"); const kolorist_1 = require("kolorist"); function useStateGen(str) { try { if (!str || str === "") { return ""; } str = str.trim(); const bigSmall = (0, bigSmallLetter_1.strToSmallAndBig)(str); const genCode = `const [ ${bigSmall[1]}, set${bigSmall[0]} ] = useState<any>(0);`; clipboardy_1.default.writeSync(genCode); console.log("Success to copy", (0, kolorist_1.yellow)(genCode), "to your clipboard."); return genCode; } catch (error) { console.log(error.message); return ""; } } exports.useStateGen = useStateGen;