Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to create new React component using create-react-app

I am using create-react-app. Is there a command to create a component to scaffold the files.

Right now I am manually creating the files. Say if the component name is Button, I create a folder named Button inside the component folder and then create Button.js and Button.css files.

Is there any CLI commands to do this using create-react-app? I know there is a way to do this Angular CLI but don't know anything with React CLI.

like image 305
phantomCoder Avatar asked Aug 21 '18 05:08

phantomCoder


1 Answers

You may use directly without installing the generate-react-cli

npx generate-react-cli component MyComponent 

Which will install a component based on your project preferences (ex: typescript, scss, etc..).

A file called generate-react-cli.json will be created where all the settings will be stored for future use.

like image 129
Leo Avatar answered Sep 21 '22 18:09

Leo