Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PurePortal<S, SS, S>

A thin wrapper around React.createPortal with

  1. Awareness of nested portals
  2. append=false to mimic old unstable_renderIntoContainer behavior for backward compatibility

Type parameters

  • S

  • SS

  • S

Hierarchy

Index

Constructors

constructor

Properties

context

getContainer

getContainer: (Anonymous function) = memoize((selector: string | HTMLElement): Element | null => {const node = getNodeFromSelector(selector);if (!node) {return node;}if (!this.props.append) {removeAllChildren(node);}return node;})

Readonly props

props: Readonly<IPurePortalProps> & Readonly<{ children?: ReactNode }>

refs

refs: {}

Type declaration

  • [key: string]: ReactInstance

state

state: Readonly<S>

Static contextType

contextType: Context<IPortalContext> = PortalContext

Methods

Optional UNSAFE_componentWillMount

  • UNSAFE_componentWillMount(): void

Optional UNSAFE_componentWillReceiveProps

  • UNSAFE_componentWillReceiveProps(nextProps: Readonly<IPurePortalProps>, nextContext: any): void

Optional UNSAFE_componentWillUpdate

  • UNSAFE_componentWillUpdate(nextProps: Readonly<IPurePortalProps>, nextState: Readonly<S>, nextContext: any): void

Optional componentDidCatch

  • componentDidCatch(error: Error, errorInfo: ErrorInfo): void
  • Catches exceptions generated in descendant components. Unhandled exceptions will cause the entire component tree to unmount.

    Parameters

    • error: Error
    • errorInfo: ErrorInfo

    Returns void

componentDidMount

  • componentDidMount(): void

Optional componentDidUpdate

  • componentDidUpdate(prevProps: Readonly<IPurePortalProps>, prevState: Readonly<S>, snapshot?: SS): void
  • Called immediately after updating occurs. Not called for the initial render.

    The snapshot is only present if getSnapshotBeforeUpdate is present and returns non-null.

    Parameters

    • prevProps: Readonly<IPurePortalProps>
    • prevState: Readonly<S>
    • Optional snapshot: SS

    Returns void

Optional componentWillMount

  • componentWillMount(): void

Optional componentWillReceiveProps

  • componentWillReceiveProps(nextProps: Readonly<IPurePortalProps>, nextContext: any): void

componentWillUnmount

  • componentWillUnmount(): void

Optional componentWillUpdate

  • componentWillUpdate(nextProps: Readonly<IPurePortalProps>, nextState: Readonly<S>, nextContext: any): void

contains

  • contains(el: Node): boolean

forceUpdate

  • forceUpdate(callback?: () => void): void
  • Parameters

    • Optional callback: () => void
        • (): void
        • Returns void

    Returns void

Optional getSnapshotBeforeUpdate

  • getSnapshotBeforeUpdate(prevProps: Readonly<IPurePortalProps>, prevState: Readonly<S>): SS | null
  • Runs before React applies the result of render to the document, and returns an object to be given to componentDidUpdate. Useful for saving things such as scroll position before render causes changes to it.

    Note: the presence of getSnapshotBeforeUpdate prevents any of the deprecated lifecycle events from running.

    Parameters

    Returns SS | null

render

  • render(): ReactPortal

setState

  • setState<K>(state: ((prevState: Readonly<S>, props: Readonly<IPurePortalProps>) => S | {}) | (S | {}), callback?: () => void): void
  • Type parameters

    • K: keyof S

    Parameters

    • state: ((prevState: Readonly<S>, props: Readonly<IPurePortalProps>) => S | {}) | (S | {})
    • Optional callback: () => void
        • (): void
        • Returns void

    Returns void

Optional shouldComponentUpdate

  • shouldComponentUpdate(nextProps: Readonly<IPurePortalProps>, nextState: Readonly<S>, nextContext: any): boolean
  • Called to determine whether the change in props and state should trigger a re-render.

    Component always returns true. PureComponent implements a shallow comparison on props and state and returns true if any props or states have changed.

    If false is returned, Component#render, componentWillUpdate and componentDidUpdate will not be called.

    Parameters

    Returns boolean

Object literals

Private Readonly childContext

childContext: object

children

children: undefined[] = []

Static defaultProps

defaultProps: object

append

append: boolean = false

Generated using TypeDoc