Generate React components in current execute directory by typing with CLI.
Works on Windows / MacOS / Linux.
We are updating to V2 which supporting
Typescript
in default. If you are upgraded from V1, please be care that you do not have to useTypescript -t
flag from now on. Instead of Javascript users, you have to apply theJavascript -j
flag.
- Create a basic components with ts / js config.
- Follow the practice of react official ts / js docs.
- Generate Components / Slice / useState in one line.
- No configs, easy to use with prompts.
Recommended: Install with -g
npm i -g react-generate-comp
Alternative: Use with npm exec
directly
# With CLI
npm exec react-generate-comp
# Call With Args
npm exec react-generate-comp -- -c HelloComp
Generate Component
rgc -c <Components names>
rgc <javascript Flag> -c <Components name>
<Javascript Flag>
-j, --javascript For enable javascript jsx generate
<React native Flag>
-n, --native For generate react native components
<Components name>
-c, --components for Generate comp name
<useState name>
-u, --useState Generate useState line code to your clipboard
<useEffect>
-e, --useEffect Generate useEffect code to your clipboard
Usage:
Create a TSX components named "HelloComp" for `React`
rgc -c helloComp
Create two TSX components named "HelloComp" and "ByeComp" for `React`
rgc -c helloComp ByeComp
Create a JSX components named "Yolocomp" for `React`
rgc -j -c yolocomp
Create a TSX components named "HelloComp" for `React native`
rgc -n -c helloComp
Create a jsx components named "Yolocomp" for `React native`
rgc -j -n -c yolocomp
Create a useState named with "[ number, setNumber ]"
rgc -u number
Create a set of folder and file for init the new Vite / CRP project
rgc -i
Create useEffect code
rgc -e
rgc -t -c "testComp"
Template
rgc -c "hiComp"
Template
rgc -t -s "todo"
Template
rgc -s "todo"
Template
- ✅ First class typescript support
- ✅ Generate other related stuff
- ⬜️ Init more template
- Add react useEffect generate
-e
flag
- Default generating
.tsx
,.ts
for all related files. - Remove
RTK Slice
generation. - Allow to create more than one componnents with same command.
- Better UX for reminder.
- Add react native component generate
-n
flag
- Add zustand template to
rgc --init
- Cli
-c
,-s
will not overwrite file that already exist in the current path.
-
init project javascript
will not generate interface folder from now.
- Added
rgc --init
prompt features. - Added RTK generate in init project features.
- Fixing bug on prompt cancel issues.
- Fixing RTKSlice Ts spacing issues.
- Better reminder prompt.
- Added
rgc --init
functions for init project folder data.
- Updated generate log syntax.
- Now typing
rgc
will active a prompts interface to select regarding generate stuff. - Color log improvement.
- Added
rgc -u <setState_name>
generate function.
MIT