Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zeckdude opened this issue Nov 1, 2020 · 0 comments
Open

Comments

@zeckdude
Copy link

zeckdude commented Nov 1, 2020

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() !== '() => {}';
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant