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

Export testOmitPropsOnStringTag for external usage #611

Closed
Andarist opened this issue Apr 3, 2018 · 5 comments · Fixed by #612
Closed

Export testOmitPropsOnStringTag for external usage #611

Andarist opened this issue Apr 3, 2018 · 5 comments · Fixed by #612
Assignees

Comments

@Andarist
Copy link
Member

Andarist commented Apr 3, 2018

Problem description:

I have custom SVG components and I'd like to filter out DOM props before passing them to a component that renders svg (and it doesnt do anything else than that).

Suggested solution:

Just export this util so it can be reused in application code. Probably could be a separate package? Can prepare a PR for this if find it useful.

Maybe we could just expose omitFn as static property on the returned Styled class (or accept it as config option in createStyled) - that way one could override it nicely without introducing unnecessary component layer.

@Andarist
Copy link
Member Author

Andarist commented Apr 4, 2018

@mitchellhamilton cool! thank you ❤️ any plans to release this in 9.x line (I can live with duplication for now, just wondering)

Also could u comment on this one:

Maybe we could just expose omitFn as static property on the returned Styled class (or accept it as config option in createStyled) - that way one could override it nicely without introducing unnecessary component layer.

EDIT:// I guess this won't be included 9.x line, as next is even a separate repo now, not only a branch 😅

@emmatown
Copy link
Member

emmatown commented Apr 5, 2018

It's already used in 9.x.

import isPropValid from '@emotion/is-prop-valid'

In regards to the omitFn option, I think it definitely could be useful(especially for styled-system which I really like so 👍 ) so I'd be happy to accept a PR though it should probably be called shouldForwardProp. I think it should probably be a option to styled since a static property feels hacky. Since we modify the options to styled in the babel plugin, I'm thinking we should accept options from the second and third arguments where the second overwrites the third and if there's a second argument passed to styled that's not an object literal, we put the options from babel on the third argument. This way, if someone uses a helper or something for the options argument, the options won't be overwritten and labels and stuff with still work.

@tkh44 do you have any thoughts on this?

@Andarist
Copy link
Member Author

Andarist commented Apr 5, 2018

Actually existing options are preserved (like proposed shouldForwardProp) while transforming since #584 . So it should be just matter of supporting this option in the code, no change to arguments order etc should be needed.

@emmatown
Copy link
Member

emmatown commented Apr 5, 2018

I meant if this happens but it's probably pretty uncommon so let's just leave it.

@Andarist
Copy link
Member Author

Andarist commented Apr 5, 2018

Yeah, it's rather uncommon especially that it's not officially supported to pass there anything more than what babel plugin adds and which is already an object.

Gonna prepare a PR soon for this so we can discuss it further under it.

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

Successfully merging a pull request may close this issue.

2 participants