import React, { Component } from 'react'; const RootDialogContext = React.createContext({}); export class RootDialogProvider extends Component { constructor (props) { super(props); this.state = { value: { title: null, setRootDialogMessage: ({ title, bodyText, variant }) => { const { value } = this.state; this.setState({ value: { ...value, title, bodyText, variant } }); }, clearRootDialogMessage: () => { const { value } = this.state; this.setState({ value: { ...value, title: null, bodyText: null, variant: null } }); } } }; } render () { const { children } = this.props; const { value } = this.state; return ( {children} ); } } export const RootDialog = ({ children }) => ( {value => children(value)} ); export function withRootDialog (Child) { return (props) => ( {context => } ); }