gc-react is a cli tool to generate react components quickly. You can use one of the templates or add your own to cut down on the boilerplate typing time and to reduce typos.
$ npm install gc-react --save-dev
$ yarn add gc-react -D
// package.json
"scripts":{
...
"gc":"gc"
}
$ npm install -g gc-react
$ yarn gc create 'component_name'
$ npm run gc create 'component_name'
$ gc create 'component_name'
$ yarn gc remove 'component_name'
$ npm run gc remove 'component_name'
$ gc remove 'component_name'
You can specify options with command line arguments and/or by creating a gc-react.config.json file at the root of your project.
Typing --template yourtemplate
all the time gets tedious, so you should at least create the file and specify the template.
// filename : gc-react.config.json
{
"template" : 'fireship',
}
If specified, the command will try to find and add an import to a styles/global.scss file. Should be used with the ts-globalScss template.
- fireship
- ts-globalScss
- js-nextjs
- ts-nextjs
- ts-tailwind
$ gc create navbar --template fireship
Otherwise, you can overwrite the default template folder by creating your own at the root of your project.
Given that you have a 'template' folder at the root of your project, the tool will look for a 'template/$customTemplateName' folder instead of using one of the builtin ones
// filename : gc-react.config.json
{
"dryRun": boolean,
"template" : string,
"quiet: boolean
}