A command line interface tool that seeks to automate some tasks when working on a React.js project.
Install the react command line tool globally so you can use it from any project directory.
$ npm install -g madebyform/react-cli
$ react new my-app
This command sets up a new react application inside the my-app
directory. This is what you get out of the box:
- Isomorphic Node configuration
- ES6 support via babel
- Express server + EJS templating system
- React router configuration
The application will have the following directory structure:
my-app/
assets/
src/
components/
utils/
views/
$ react generate MyComponent firstProp:string secondProp:requiredObject
This creates a skeleton mycomponent.jsx
file inside your src/components
directory.
By default, the resulting file includes React lifecycle methods, like componentWillMount
. You can skip these by passing in either -l
or --skip-lifecycle
to the command above. To know more run $ react generate -h
.
Currently supported property types:
Optional Props | Required Props |
---|---|
any | requiredAny |
array | requiredArray |
bool | requiredBool |
func | requiredFunc |
number | requiredNumber |
object | requiredObject |
string | requiredString |
Use the --help
flag for a complete list of options and commands.
$ react --help
Usage: react <command> [options]
Commands:
new <name> Generate a new react app boilerplate.
generate [options] <name> [propName:PropType...] Generate a new react component.
Options:
-h, --help output usage information
-V, --version output the version number
Available under the MIT license.