Skip to content

Instantly share code, notes, and snippets.

@MichalZalecki
Created July 9, 2016 19:13
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 MichalZalecki/8bdea608881b68466ee5a72fe723808f to your computer and use it in GitHub Desktop.
Save MichalZalecki/8bdea608881b68466ee5a72fe723808f to your computer and use it in GitHub Desktop.
Mount Cycle.js app as react component
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