Skip to content

Commit 1905c07

Browse files
committed
Add documentation
1 parent 89d0cb6 commit 1905c07

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ Prerendering is set to `true` by default, but can be turned off with `prerender:
649649
You can generate a new component file with:
650650

651651
```sh
652-
rails g react:component ComponentName prop1:type prop2:type ...
652+
rails g react:component ComponentName prop1:type prop2:type ... [options]
653653
```
654654

655655
For example,
@@ -682,9 +682,38 @@ var Post = createReactClass({
682682

683683
The generator also accepts options:
684684

685+
- `--function` or `--func`: use `function ComponentName() {...}`
685686
- `--es6`: use `class ComponentName extends React.Component`
686687
- `--coffee`: use CoffeeScript
687688

689+
For example,
690+
691+
```sh
692+
rails g react:component ButtonComponent title:string --function
693+
```
694+
695+
would generate:
696+
697+
```jsx
698+
import React from "react"
699+
import PropTypes from "prop-types"
700+
701+
function ButtonComponent() {
702+
return (
703+
<React.Fragment>
704+
Title: {this.props.title}
705+
</React.Fragment>
706+
);
707+
}
708+
709+
ButtonComponent.propTypes = {
710+
title: PropTypes.string
711+
};
712+
713+
export default ButtonComponent
714+
715+
```
716+
688717
Accepted PropTypes are:
689718

690719
- Plain types: `any`, `array`, `bool`, `element`, `func`, `number`, `object`, `node`, `shape`, `string`

0 commit comments

Comments
 (0)