Skip to content

Commit ff56602

Browse files
committed
Add documentation
1 parent 97eef5a commit ff56602

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
@@ -648,7 +648,7 @@ Prerendering is set to `true` by default, but can be turned off with `prerender:
648648
You can generate a new component file with:
649649

650650
```sh
651-
rails g react:component ComponentName prop1:type prop2:type ...
651+
rails g react:component ComponentName prop1:type prop2:type ... [options]
652652
```
653653

654654
For example,
@@ -681,9 +681,38 @@ var Post = createReactClass({
681681

682682
The generator also accepts options:
683683

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

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

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

0 commit comments

Comments
 (0)