Skip to content

Add mapThemrProps option #59

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
merged 1 commit into from
May 12, 2017
Merged

Add mapThemrProps option #59

merged 1 commit into from
May 12, 2017

Conversation

javivelasco
Copy link
Owner

@javivelasco javivelasco commented May 12, 2017

This PR brings a new option and property to the decorator than can be very useful in some scenarios. Until now, we were passing a ref prop always to the decorated component with the withRef property. This is not always the case: picture that you have a component that is decorated already with an HOC that maps innerRef to ref. For those cases you can use the new mapThemrProps option/prop.

It receives all properties given to the component (included themr ones) and the generated theme object and it should return the properties that you want to pass down. For the exposed scenario you might want:

function mapThemrProps(props, theme) {
  const { composeTheme, innerRef, mapThemrProps, themeNamespace, ...rest } = props;
  return { ...rest, withRef: innerRef, theme };
}

Check the tests to see a full use case.

@javivelasco
Copy link
Owner Author

This needs an update of typings @raveclassic

@javivelasco
Copy link
Owner Author

Backwards compatible so merging :)

@javivelasco javivelasco merged commit 4dbb6b6 into master May 12, 2017
@javivelasco javivelasco deleted the map-themr-props branch May 12, 2017 10:57
javivelasco added a commit that referenced this pull request May 12, 2017
* 'master' of github.com:javivelasco/react-css-themr:
  Add mapThemrProps option (#59)
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 this pull request may close these issues.

1 participant