How to use the react-dom.createPortal function in react-dom

To help you get started, we’ve selected a few react-dom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github catamphetamine / react-responsive-ui / source / Tooltip.js View on Github external
render()
	{
		// Shows tooltip on mouse over when on desktop.
		// Shows tooltip on touch when on mobile.

		// `ReactDOM.createPortal()` requires React >= 16.
		// If it's not available then it won't show the tooltip.

		const content = this.renderContent()

		const tooltip = this.tooltip && content && ReactDOM.createPortal &&
			ReactDOM.createPortal(content, this.tooltip)

		// For React >= 16.2.
		// Disable React portal event bubbling.
		// https://github.com/facebook/react/issues/11387#issuecomment-340019419
		if (React.Fragment) {
			return (
				
					{this._render()}
					{tooltip}
				
			)
		} else {
			// Legacy version support.
			// Can be a bit buggy in some rare cases of mouseentering and mouseleaving.
			// Will be removed in some future major version release.
			return this._render(tooltip)
github fontIconPicker / react-fonticonpicker / src / js / components / FipDropDownPortal.jsx View on Github external
this.props.className,
			this.state.portalClasses,
		);
		const fipDropDownNode = (
			<div>
				{this.props.children}
			</div>
		);
		// should we render to a portal or
		// just usual?
		if (this.state.appendRoot === 'self') {
			// render to the App itself
			return fipDropDownNode;
		}
		// render to the DOM
		return createPortal(fipDropDownNode, this.state.appendRoot);
	}
}
github OlegChulakovStudio / chramework / src / components / Player / Player.js View on Github external
const PlayIconInject = ({ renderNode }) =&gt;
	ReactDOM.createPortal(
		,
		renderNode
	);
github samlogan / universal-firebase-react / app / components / Auth / AuthModal.jsx View on Github external
render() {
    const { type } = this.state;
    const { active, closeAuthModal } = this.props;
    if (!active) return <span>;
    return ReactDOM.createPortal(
      <div> this.handleModalBackgroundClick(event)}&gt;
        <div>
          <div>
            <h3>{getModalTitle(type)}</h3>
          </div>
          {this.getAuthForm(type)}
           closeAuthModal(event)}&gt;Close
        </div>
      </div>,
      appRoot
    );
  }
}</span>
github littleorca / ferris-wheel / ui / react / src / form / AutoForm.tsx View on Github external
const properContainerFunc = (props: { children: React.ReactNode[] }) => {
        return ReactDOM.createPortal(props.children, document.body);
    };
github PaulLeCam / react-leaflet / src / DivOverlay.js View on Github external
render() {
    if (this.leafletElement._contentNode) {
      return createPortal(this.props.children, this.leafletElement._contentNode)
    }
    return null
  }
}
github mockingbot / ibot / components / guide / index.js View on Github external
render () {
    const { children = null } = this.props

    const base = (
      isValidElement(children)
        ? cloneElement(children, { ref: this.set$base })
        : <span>{ children }</span>
    )

    const guide = createPortal(this.renderGuide(), this.portal)

    return (
      
        { base }
        { guide }
      
    )
  }
github devexperts / dx-platform / packages / react-kit / src / components / Popover / Popover.tsx View on Github external
)}
						{this.props.children}
					
				
			
		);

		if (closeOnClickAway) {
			child = {child};
		}

		const target = typeof window !== 'undefined' ? window : 'window';

		return (
			
				{ReactDOM.createPortal(child, this.rootElement)}
			
		);
	}
github ryanseddon / react-frame-component / src / Frame.jsx View on Github external
<div>{this.props.children}</div>
        
      
    );

    if (initialRender) {
      doc.open('text/html', 'replace');
      doc.write(this.props.initialContent);
      doc.close();
      this._setInitialContent = true;
    }

    const mountTarget = this.getMountTarget();

    return [
      ReactDOM.createPortal(this.props.head, this.getDoc().head),
      ReactDOM.createPortal(contents, mountTarget)
    ];
  }
github blablacar / ui-library / src / snackbar / Snackbar.tsx View on Github external
className="kirk-snackbar-cross"
                onClick={this.props.close}
              &gt;
                
              
            
          
        )}
      
    )

    if (!this.portalNode) {
      return modalElement
    }

    return createPortal(modalElement, this.portalNode)
  }
}