import {
    type ReactNode
} from "react";
import {
    Consumer
} from "./Consumer";
import {
    Context
} from "./Host";

interface IPortalProps {
    children: ReactNode;
    name?: string;
}

export const Portal = ({
    children,
    name
}: IPortalProps): ReactNode => (
    <Context.Consumer>
        {(manager): ReactNode => {
            return <Consumer
                manager={manager}
                name={name}
            >
                {children}
            </Consumer>;
        }}
    </Context.Consumer>
);
