Skip to content

button-has-type not recognizing default props #1846

Closed
@pascalduez

Description

@pascalduez

Hi,

looks like whatever I try the button-has-type rule can't understand the default prop.

type Props = {
  type: 'submit' | 'button' | 'reset',
};

function Button({ type, ...extraProps }: Props) {
  return <button type={type} {...extraProps} />;
}

Button.defaultProps = {
  type: 'submit',
};
error  "null" is an invalid value for button type attribute  react/button-has-type
type Props = {
  type: 'submit' | 'button' | 'reset',
};

function Button({ type = 'submit', ...extraProps }: Props) {
  return <button type={type} {...extraProps} />;
}
error  "null" is an invalid value for button type attribute  react/button-has-type

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions