Skip to content

Add an option to omit default props that are empty function callbacks #585

Open
@zeckdude

Description

@zeckdude

Often times a callback prop is assigned an empty function (() => {}) as the default value. The showDefaultProps method is simply looking for equality (I believe), so it won't catch a default prop that is just an empty function. In those cases, I had to add some logic in the filterProps property to make those not appear but I don't think this is the best solution and I would love it if the showDefaultProps would catch those as well or if there was another option I can set so those empty functions don't show up in the generated string.

filterProps: value => {
  // Omit empty functions (they're likely from default props and `showDefaultProps` doesn't catch those)
  if (!isFunction(value)) {
    return true;
  }

  return value.toString() !== '() => {}';
},

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