0.2.3 • Published 8 years ago
reactjs-init v0.2.3
reactjs-init 中文版
A command line tool that generates a React.js project boilerplate.
Getting Started
$ npm install -g reactjs-init
Commands
Generate a boilerplate.
$ reactjs new react-demo
THEN
$ cd react-demo
$ npm install
$ npm run start
# Enjoy it !
The project will have the following directory structure:
react-demo/
src/
components/
App/
App.jsx
style.less
index.jsx
index.html
index.jsx
style.less
.babrlrc
.eslintrc
.eslintignore
.gitignore
package.json
webpack.config.js
webpack.prd.config.js
README.md
Generate a React component.
$ reactjs generate MyComponent
This command will creates a directory MyComponent
inside your src/components
directory.
This component will have the following directory structure:
MyCompnent/
MyCompnent.js
style.less
index.js
Component Lifecycle methods
By default, the component will be included React lifecyle methods(eg: componentWillMount/componentWillUpdate...), but you can not generate these lifecyle methods by passing an option -s
with the command.
eg:
$ reactjs generate -s MyComponent
Property Types
Currently supported property types:
Optional Props | Required Props |
---|---|
any | requiredAny |
array | requiredArray |
bool | requiredBool |
func | requiredFunc |
number | requiredNumber |
object | requiredObject |
string | requiredString |
You can add some propTypes with the component, command just like following this:
$ reactjs generate MyComponent componentPropA:any componentPropB:bool
Usage
$ reactjs --help
Usage: reactjs <command> [options]
Commands:
new <name>
Generate a new React.js boilerplate project.
generate [options] <Component> [propName:PropType...]
Generate a new react component.
Options:
-h, --help output usage information
-V, --version output the version number