Skip to content

Instantly share code, notes, and snippets.

@queckezz
Created September 15, 2015 18:40
Show Gist options
  • Save queckezz/4a73d51614c2b568822c to your computer and use it in GitHub Desktop.
Save queckezz/4a73d51614c2b568822c to your computer and use it in GitHub Desktop.
react componentes as functions
import ReactInstance from 'react'
const create = React => {
return function (init, fn) {
if (arguments.length == 1) {
fn = init
init = null
}
return React.createClass({
getInitialState: () => init || {},
render () {
return fn({
comp: this,
props: this.props,
state: this.state,
children: this.props.children
})
}
})
}
}
export default create(ReactInstance)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment