// @flow import * as React from 'react'; import createContext, { type Context } from '@hypnosphi/create-react-context'; export const ManagerReferenceNodeContext: Context = createContext(); export const ManagerReferenceNodeSetterContext: Context< void | ((?HTMLElement) => void) > = createContext(); export type ManagerProps = { children: React.Node, }; export default class Manager extends React.Component { referenceNode: ?HTMLElement; setReferenceNode = (newReferenceNode: ?HTMLElement) => { if (newReferenceNode && this.referenceNode !== newReferenceNode) { this.referenceNode = newReferenceNode; this.forceUpdate(); } }; componentWillUnmount() { this.referenceNode = null; } render() { return ( {this.props.children} ); } }