Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
armandabric merged 1 commit into algolia:master from bschlenk:filter-props
Jan 17, 2020
Merged

feat: allow filterProps to be a function #417

armandabric merged 1 commit into algolia:master from bschlenk:filter-props
Jan 17, 2020

Conversation

Copy link
Contributor

@bschlenk bschlenk commented Sep 18, 2019

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

leonelgalan reacted with thumbs up emoji
Copy link
Collaborator

Thanks for rebasing this PR 👍 I will have a look into it in the next days

Copy link
Collaborator

@armandabric armandabric left a 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:

filterProps: string[],

Copy link

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.

Copy link
Collaborator

Let's do this! 🚀

leonelgalan reacted with thumbs up emoji

@armandabric armandabric merged commit c4908bb into algolia:master Jan 17, 2020
Copy link
Collaborator

Released in v14.3.0

Copy link

elliotgeno commented Feb 14, 2020
edited
Loading

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; } }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@armandabric armandabric armandabric approved these changes

Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

API request: filterFunction

AltStyle によって変換されたページ (->オリジナル) /