import * as React from 'react'; import * as PropTypes from 'prop-types'; import { RedocNormalizedOptions, RedocRawOptions } from '../services/RedocNormalizedOptions'; export interface OptionsProviderProps { options: RedocRawOptions; } export class OptionsProvider extends React.Component { static childContextTypes = { redocOptions: PropTypes.object.isRequired, }; getChildContext() { return { redocOptions: new RedocNormalizedOptions(this.props.options), }; } render() { return React.Children.only(this.props.children); } } export class ComponentWithOptions

extends React.Component { static contextTypes = { redocOptions: PropTypes.object, }; get options(): RedocNormalizedOptions { return this.context.redocOptions || {}; } }