Skip to content

Rule require-default-props does not support default parameters in stateless function #1009

Closed
@preco21

Description

@preco21

Hello, I just got some error from require-default-props rule:

`react/require-default-props`:  propType "foo" is not required, but has no corresponding defaultProp declaration.
`react/require-default-props`:  propType "baz" is not required, but has no corresponding defaultProp declaration.

Here is the code:

function Header({
  foo = true,
  bar,
  baz = () => { /* noop */ },
}) {
  return ...;
}

Header.propTypes = {
  foo: PropTypes.bool,
  bar: PropTypes.bool.isRequired,
  baz: PropTypes.func,
};

I expected there is no error, but seems it causes the problem.

Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions