Skip to content
This repository has been archived by the owner on Aug 28, 2022. It is now read-only.

Commit

Permalink
fix(create-glamorous): forward nativeProps to inner component (#29)
Browse files Browse the repository at this point in the history
HOC should always forward native properties to their inner components

closes #28
  • Loading branch information
atticoos authored May 18, 2017
1 parent 17273cd commit b595faf
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/create-glamorous.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ export default function createGlamorous(splitProps) {
state = {theme: null}
setTheme = theme => this.setState({theme})

constructor(props, context) {
super(props, context)
this.onRef = this.onRef.bind(this)
}

componentWillMount() {
const {theme} = this.props

Expand All @@ -72,6 +77,19 @@ export default function createGlamorous(splitProps) {
this.unsubscribe && this.unsubscribe()
}

setNativeProps(nativeProps) {
if (this.innerComponent) {
this.innerComponent.setNativeProps(nativeProps)
}
}

onRef(innerComponent) {
this.innerComponent = innerComponent
if (this.props.innerRef) {
this.props.innerRef(innerComponent)
}
}

render() {
const props = this.props

Expand All @@ -93,7 +111,7 @@ export default function createGlamorous(splitProps) {

return React.createElement(GlamorousComponent.comp, {
...toForward,
ref: props.innerRef,
ref: this.onRef,
style: fullStyles.length > 0 ? fullStyles : null,
})
}
Expand Down

0 comments on commit b595faf

Please sign in to comment.