Sha256: 5b4737708553cdc23917b9e0fcf71542f9cbb9633e5fb8a5c99fffa93ae84bcb
Contents?: true
Size: 1.05 KB
Versions: 2
Compression:
Stored size: 1.05 KB
Contents
import React from 'react'; import ObjectResolver from './resolvers/object_resolver'; export default function(Component, options) { options = options || {}; if (options.editorOnly && !PAGEFLOW_EDITOR) { return class extends React.Component { render() { return false; } }; } return class extends React.Component { static contextTypes = { resolverSeed: React.PropTypes.object } constructor(props, context) { super(props, context); this._resolver = new ObjectResolver( options.fragments, this._handleChange.bind(this) ); this.state = this._resolve(props); } componentWillReceiveProps(nextProps) { this.setState(this._resolve(nextProps)); } componentWillUnmount() { this._resolver.dispose(); } _handleChange() { this.setState(this._resolve(this.props)); } _resolve(props) { return this._resolver.get(props, this.context.resolverSeed); } render() { return (<Component {...this.state} />); } }; };
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pageflow-react-0.1.1 | js/src/create_container.jsx |
pageflow-react-0.1.0 | js/src/create_container.jsx |