Created
September 15, 2015 18:40
-
-
Save queckezz/4a73d51614c2b568822c to your computer and use it in GitHub Desktop.
react componentes as functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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