Socket
Socket
Sign inDemoInstall

@uiw/react-portal

Package Overview
Dependencies
2
Maintainers
2
Versions
169
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uiw/react-portal

Portal component


Version published
Maintainers
2
Install size
7.21 kB
Created

Readme

Source

Portal 入口

Buy me a coffee Open in unpkg NPM Downloads npm version

Portals 是 react 16 提供的官方解决方案,使得组件可以脱离父组件层级挂载在 DOM 树的任何位置,我们利用这个方法,可将模态对话框生成到根节点的外面。

import { Portal } from 'uiw';
// or
import Portal from '@uiw/react-portal';

基本使用

import { Portal } from 'uiw';

<Portal>
  此文本在 document.body 的末尾传送!
</Portal>
<Portal node={document && document.getElementById('dom-id')}>
  此文本在显示在 dom-id 的 dom 对象中 
</Portal>

切换不同的 <Portal />

{isVisiable && <Portal>切换不同的 Portal</Portal>}

Props

参数说明类型默认值
container指定容器节点生成,服务端渲染默认为 nullanydocument.body
visible当值为 true 的时候才会创建 createPortal,可避免初始化创建多余的 dom 节点挂载 @v4.9.0+ 之后移除了boolean-
onChildrenMount渲染后的回调函数 @v4.9.0+ 之后移除了() => void-

Keywords

FAQs

Last updated on 29 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc