import { FC } from 'react';
import { createPortal } from 'react-dom';
import { PortalProps } from 'types';
import { useComponentLogic } from './hooks';

export const Portal: FC<PortalProps> = props => {
	const { children } = props;
	const target = useComponentLogic(props);
	return createPortal(children, target);
};

Portal.defaultProps = {
	id: 'portal',
	testId: 'portal-test-id',
};

export default Portal;
