# All files / src/Portal Portal.tsx

100% Statements 10/10
100% Branches 2/2
100% Functions 1/1
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    2665x
    65x
    65x
    65x

    65x
    183x
    183x
    183x

    183x

    183x

     import React from 'react'
    import ReactDOM from 'react-dom'
    import { useZIndexContext } from '../_hooks/ZIndex'
    import { StyledPortal } from './Portal.styles'
    import { PortalProps } from './Portal.types'

    /**
     * @deprecatedSince 11
     * @deprecated Intended for internal library development.
     * @see [Storybook](https://procore.github.io/core/core-react/latest/?path=/story/coverage-portal--defaults)
     */
    export function Portal({
      children,
      container,
      ...props
    }: PortalProps): React.ReactPortal {
      const zIndexCtx = useZIndexContext()

      return ReactDOM.createPortal(
        <StyledPortal {...props} style={{ zIndex: zIndexCtx.value }}>
          {children}
        </StyledPortal>,
        container || document.body
      )
    }