Skip to content

Instantly share code, notes, and snippets.

@dbilgili
Last active December 9, 2018 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbilgili/a3020d67d8c23aab701cc9da9461a925 to your computer and use it in GitHub Desktop.
Save dbilgili/a3020d67d8c23aab701cc9da9461a925 to your computer and use it in GitHub Desktop.
// vim: syntax=JSX
render(){
const { children } = this.props
const { isOpen, style } = this.state
const inputChildren = React.Children.map(children, child => {
if(child.type.displayName === "Select"){
return React.cloneElement(child, {open: this.open})
}
else{
return (
isOpen && ReactDOM.createPortal(
<span style={style}>{React.cloneElement(child)}</span>, document.body
)
)
}
})
return inputChildren
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment