Skip to content

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.

2 participants