import * as React from 'react'; import { RefStack } from './utils/RefStack'; import { NestingContext } from './NestingContext'; import { NestingProps, NodeRef } from './types'; export class NestingRoot extends React.Component { registry = new RefStack(); parentRef = React.createRef(); componentDidMount() { this.registry.register(this.parentRef as any); } componentWillUnmount() { this.registry.unregister(this.parentRef as any); } getRefs = (): NodeRef[] => this.registry.getContextRefs(this.parentRef as any); render() { return ( {this.props.children(this.getRefs, this.parentRef as any)} ); } }