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
# Prevent usage of `button` elements without an explicit `type` attribute (react/jsx-no-typeless-button)
2
+
3
+
The default value of `type` attribute for `button` HTML element is `"submit"` which is often not the desired behavior and may lead to unexpected page reloads.
4
+
This rules enforces an explicit `type` attribute for all the `button` elements.
5
+
6
+
## Rule Details
7
+
8
+
The following patterns are considered errors:
9
+
10
+
```jsx
11
+
var Hello =<button>Hello</button>
12
+
```
13
+
14
+
The following patterns are **not** considered errors:
15
+
16
+
```jsx
17
+
var Hello =<span>Hello</span>
18
+
var Hello =<button type="button">Hello</button>
19
+
var Hello =<button type="submit">Hello</button>
20
+
var Hello =<button type="reset">Hello</button>
21
+
```
22
+
23
+
## When Not To Use It
24
+
25
+
If you use only `"submit"` buttons, you can disable this rule
0 commit comments