generate-component-react is a CLI generator for ReactJS components based on specified name and options.
Use the package manager npm to install
npm install -g generate-component-react
Make sure to execute the commands from your app root directory
generate component <component-name> -f
or
gc <component-name> --function
generate component <component-name> -c
or
gc <component-name> --class
Following options can be used optionally,
--css : add a CSS module for the generated component, e.g.,
generate component <component-name> --class --css
-s or --state : add state to the generated component, e.g.,
generate component <component-name> --class --state
-
Sample component (functional component with state and css):
generate component sample --function --css --state CREATED <app-root-dir>\src\sample\sample.css CREATED <app-root-dir>\src\sample\sample.js CREATED <app-root-dir>\src\sample\index.js
-
Sample component (class based component without state but with css):
generate component sample --class --css CREATED <app-root-dir>\src\sample\sample.css CREATED <app-root-dir>\src\sample\sample.js CREATED <app-root-dir>\src\sample\index.js
-
Sample component (functional component in nested directory without state and css):
generate component components/sample --function CREATED <app-root-dir>\src\components\sample\sample.js CREATED <app-root-dir>\src\components\sample\index.js
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.