Created
July 9, 2016 19:13
-
-
Save MichalZalecki/8bdea608881b68466ee5a72fe723808f to your computer and use it in GitHub Desktop.
Mount Cycle.js app as react component
This file contains 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 React, { PropTypes, Component } from "react"; | |
import ReactDOM from "react-dom"; | |
import { makeDOMDriver } from "@cycle/dom"; | |
import { run } from "@cycle/xstream-run"; | |
class CycleRun extends Component { | |
static propTypes = { | |
main: PropTypes.func.isRequired, | |
drivers: PropTypes.object, | |
}; | |
static defaultProps = { | |
drivers: {}, | |
}; | |
componentDidMount() { | |
const drivers = { | |
...this.props.drivers, | |
DOM: makeDOMDriver(ReactDOM.findDOMNode(this)), | |
}; | |
run(this.props.main, drivers); | |
} | |
render() { | |
return <div />; | |
} | |
} | |
export default CycleRun; | |
// Usage | |
// | |
// <Cycle main={Counter} /> | |
// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment