UNPKG

@pisano/react-frame-component

Version:

React component to wrap your application or component in an iFrame for encapsulation purposes

27 lines (22 loc) 642 B
import React, { Component, Children } from 'react'; // eslint-disable-line no-unused-vars import PropTypes from 'prop-types'; export default class DocumentContext extends Component { static propTypes = { document: PropTypes.object.isRequired, window: PropTypes.object.isRequired, children: PropTypes.element.isRequired }; static childContextTypes = { document: PropTypes.object.isRequired, window: PropTypes.object.isRequired }; getChildContext() { return { document: this.props.document, window: this.props.window }; } render() { return Children.only(this.props.children); } }