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

Discussion: Abstract out prop mapping to independent lib #1601

Closed
cdaringe opened this issue Apr 20, 2017 · 2 comments
Closed

Discussion: Abstract out prop mapping to independent lib #1601

cdaringe opened this issue Apr 20, 2017 · 2 comments

Comments

@cdaringe
Copy link
Contributor

as usual, i must always begin w/ deep gratitude to @levithomason & @layershifter for kicking so much butt on this project. thanks gents.

problem statement

I want to borrow/steal your code, but I'm not clear how.

context

designing components that gracefully, happily merge user-provided props in with the default props a component provides can be tedious/verbose/difficult. I think RSUI's answer to this problem is this babel plugin? example of this discussed below.

discussion

in each RSUI component, render() juggles classnames, styles, etc, and carefully drops props into each root export. for example, see here.

we wrote a little utility here that sniffs user props, and returns those which we will pass to the root node.

function MyCompontent (props) {
  var rest = externalAttributeFilter(props)
  return <div {...rest}>...</div>
}

our solution ^above^ does not gracefully handle classNames, styles, etc. i'm interested in exploring a solution that does, and not creating a snowflake.

  • is the RSUI team content with how {...rest} props are generated?
  • are there ways to enable graceful generation of {...rest} properties external of this project?
  • if there are areas to improve here to make ^^ possible, a) would you be interested, b) can I help!

thanks for the time.

@levithomason
Copy link
Member

is the RSUI team content with how {...rest} props are generated?

Very much so.

are there ways to enable graceful generation of {...rest} properties external of this project?

The babel plugin you noted does exactly this. We also use lib/getUnhandledProps.js, though, it now just partitions props based on the handledProps generated by the babel plugin.

if there are areas to improve here to make ^^ possible, a) would you be interested, b) can I help!

We're definitely interested in this. You can see thoughts on a base component that handles all these tasks here #419. I'd like to pull all this functionality into a HOC.

@cdaringe
Copy link
Contributor Author

rad! should we just close this and focus over there? this conversation really is a sub-discussion (i think) of #419 as this topic must be addressed transitively to complete #419.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants