Skip to content

react/button-has-type Restriction

What it does

Enforces explicit type attribute for all the button HTML elements.

Why is this bad?

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.

Example

Examples of incorrect code for this rule:

jsx
<button />
<button type="foo" />

Examples of correct code for this rule:

jsx
<button type="button" />
<button type="submit" />

References

Released under the MIT License.