-
Notifications
You must be signed in to change notification settings - Fork 88
feat: allow filterProps to be a function #417
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
Conversation
Thanks for rebasing this PR 👍 I will have a look into it in the next days
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this change ! Good idea to use a function here, it's a lot more powerful for the users 😃
Before we can merge we should also edit the Options
flow definitions to allow add the functional version of the filterProps
option:
leonelgalan
commented
Jan 16, 2020
Let's get this merged! I was looking for a way to filter props with value of undefined
, having a function allows for this and more.
Let's do this! 🚀
Released in v14.3.0
I see this is still relatively fresh!!
I would like to make one improvement... Instead of optionally showing the prop with a function, I would like to override the string for the prop's value with that the filterProps function.
For example, if you provide a prop with a reference to another Component, it will try to render that as an object.
Example:
<Accordion.Toggle as={Card.Header} >
returns this string:
<Accordion.Toggle as={{ $$typeof: Symbol(react.forward_ref), defaultProps: undefined, displayName: 'Card.Header', render: function noRefCheck() {} }} >
Ideally, I could write a function that replaces that prop value with the component's displayName. Similar to how options.displayName works... but for property values.
In the above example, I would like to pass the following to filterProps:
filterProps: (value, key) => { if (key === "style") { return false } if (key === "as") { return value.displayName; } }
filterProps can now be passed as either an array of strings, or a function that will be called with the props value and key and return false to filter out that prop.
Closes #286