algolia / algolia/react-element-to-jsx-string
Add an option to omit default props that are empty function callbacks
- Dominant language
- JavaScript
- Stars
- 518
- Forks
- 87
- Avg merge
- 3h 56m
- Merged PRs (30d)
- 3
Description
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.
```js
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() !== '() => {}';
},
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.