@@ -24,6 +24,15 @@ var Hello = createReactClass({
24
24
});
25
25
```
26
26
27
+ ``` jsx
28
+ class Hello extends React .Component {
29
+ render () {
30
+ return < div> Hello< / div> ;
31
+ }
32
+ static displayName = ' Hello' ;
33
+ }
34
+ ```
35
+
27
36
Examples of ** correct** code for this rule:
28
37
29
38
``` jsx
@@ -35,6 +44,15 @@ var Hello = createReactClass({
35
44
});
36
45
```
37
46
47
+ ``` jsx
48
+ class Hello extends React .Component {
49
+ static displayName = ' Hello' ;
50
+ render () {
51
+ return < div> Hello< / div> ;
52
+ }
53
+ }
54
+ ```
55
+
38
56
## Rule Options
39
57
40
58
This rule can take one argument to customize the components organisation.
@@ -128,6 +146,16 @@ var Hello = createReactClass({
128
146
});
129
147
```
130
148
149
+ ``` jsx
150
+ class Hello extends React .Component {
151
+ render () {
152
+ return < div> Hello< / div> ;
153
+ }
154
+ onClick = this .onClick .bind (this );
155
+ onClick () {}
156
+ }
157
+ ```
158
+
131
159
Examples of ** correct** code for this rule, with the above configuration:
132
160
133
161
``` jsx
@@ -139,6 +167,16 @@ var Hello = createReactClass({
139
167
});
140
168
```
141
169
170
+ ``` jsx
171
+ class Hello extends React .Component {
172
+ onClick = this .onClick .bind (this );
173
+ onClick () {}
174
+ render () {
175
+ return < div> Hello< / div> ;
176
+ }
177
+ }
178
+ ```
179
+
142
180
If you want to split your ` render ` method into smaller ones and keep them just before render:
143
181
144
182
``` js
@@ -170,6 +208,17 @@ var Hello = createReactClass({
170
208
});
171
209
```
172
210
211
+ ``` jsx
212
+ class Hello extends React .Component {
213
+ renderButton = () => {}
214
+ onClick = this .onClick .bind (this );
215
+ onClick () {}
216
+ render () {
217
+ return < div> Hello< / div> ;
218
+ }
219
+ }
220
+ ```
221
+
173
222
Examples of ** correct** code for this rule, with the above configuration:
174
223
175
224
``` jsx
@@ -182,6 +231,17 @@ var Hello = createReactClass({
182
231
});
183
232
```
184
233
234
+ ``` jsx
235
+ class Hello extends React .Component {
236
+ onClick = this .onClick .bind (this );
237
+ onClick () {}
238
+ renderButton = () => {}
239
+ render () {
240
+ return < div> Hello< / div> ;
241
+ }
242
+ }
243
+ ```
244
+
185
245
If you want to flow annotations to be at the top:
186
246
187
247
``` js
0 commit comments