You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/rules/no-multi-comp.md
+45Lines changed: 45 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,6 +73,51 @@ module.exports = HelloJohn;
73
73
74
74
When `true` the rule will ignore components which are not exported, which allows you to define components as long as they are only used within a private scope.
75
75
76
+
Examples of **correct** code for this rule:
77
+
78
+
```jsx
79
+
exportfunctionHello(props) {
80
+
return<div>Hello {props.name}</div>;
81
+
}
82
+
functionHelloAgain(props) {
83
+
return<div>Hello again {props.name}</div>;
84
+
}
85
+
```
86
+
87
+
```jsx
88
+
functionHello(props) {
89
+
return<div>Hello {props.name}</div>;
90
+
}
91
+
classHelloJohnextendsReact.Component {
92
+
render() {
93
+
return<Hello name="John"/>;
94
+
}
95
+
}
96
+
module.exports= HelloJohn;
97
+
```
98
+
99
+
Examples of **incorrect** code for this rule:
100
+
101
+
```jsx
102
+
exportfunctionHello(props) {
103
+
return<div>Hello {props.name}</div>;
104
+
}
105
+
exportfunctionHelloAgain(props) {
106
+
return<div>Hello again {props.name}</div>;
107
+
}
108
+
```
109
+
110
+
```jsx
111
+
functionHello(props) {
112
+
return<div>Hello {props.name}</div>;
113
+
}
114
+
functionHelloAgain(props) {
115
+
return<div>Hello again {props.name}</div>;
116
+
}
117
+
module.exports= {Hello, HelloAgain}
118
+
```
119
+
120
+
76
121
## When Not To Use It
77
122
78
123
If you prefer to declare multiple components per file you can disable this rule.
0 commit comments