# @uiw/react-portal

> Portal component

Latest version **4.22.3** (published 2023-11-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install @uiw/react-portal
pnpm add @uiw/react-portal
yarn add @uiw/react-portal
bun add @uiw/react-portal
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; has provenance.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 4.22.3 |
| Published | 2023-11-29 |
| First published | 2020-05-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 740 |
| Author | Kenny Wong |
| Maintainers | uiwjs, wcjiang |
| Keywords | portal, react-portal, design, uiw, uiw-react, react.js, react, react-component, component, components, ui, css, uikit, react-ui, framework, front-end, frontend |

## Links

- npm: https://www.npmjs.com/package/@uiw/react-portal
- Repository: https://github.com/uiwjs/uiw
- Homepage: https://uiwjs.github.io/#/components/portal
- Issues: https://github.com/uiwjs/uiw/issues
- Funding: https://jaywcjlove.github.io/#/sponsor
- npm.io page: https://npm.io/package/@uiw/react-portal

## Alternatives

- [@progress/kendo-ooxml](https://npm.io/package/@progress/kendo-ooxml.md) — 152.1K weekly downloads
- [@progress/kendo-react-ripple](https://npm.io/package/@progress/kendo-react-ripple.md) — 8.0K weekly downloads
- [@progress/kendo-react-orgchart](https://npm.io/package/@progress/kendo-react-orgchart.md) — 4.3K weekly downloads
- [@praxisui/dynamic-fields](https://npm.io/package/@praxisui/dynamic-fields.md) — 2.4K weekly downloads
- [@mesalvo/react-ui](https://npm.io/package/@mesalvo/react-ui.md) — 1.7K weekly downloads

## Recent versions

- 4.22.3 (latest) — 2023-11-29
- 5.0.0-bate.2.1 (bate) — 2023-03-10
- 4.22.2 — 2023-11-09
- 4.22.1 — 2023-11-08
- 4.22.0 — 2023-09-19
- 4.21.28 — 2023-05-05
- 4.21.27 — 2023-04-21
- 4.21.26 — 2023-04-20
- 4.21.25 — 2023-03-14
- 4.21.24 — 2023-03-08
- 5.0.0-bate.2.0 — 2023-03-02
- 4.21.23 — 2022-12-21
- 4.21.22 — 2022-12-19
- 4.21.21 — 2022-12-19
- 5.0.0-bate-19 — 2022-12-12
- … 154 more at https://npm.io/package/@uiw/react-portal/versions

## README

Portal 入口
===

[![Buy me a coffee](https://img.shields.io/badge/Buy%20me%20a%20coffee-048754?logo=buymeacoffee)](https://jaywcjlove.github.io/#/sponsor)
[![Open in unpkg](https://img.shields.io/badge/Open%20in-unpkg-blue)](https://uiwjs.github.io/npm-unpkg/#/pkg/@uiw/react-portal/file/README.md)
[![NPM Downloads](https://img.shields.io/npm/dm/@uiw/react-portal.svg?style=flat)](https://www.npmjs.com/package/@uiw/react-portal)
[![npm version](https://img.shields.io/npm/v/@uiw/react-portal.svg?label=@uiw/react-portal)](https://npmjs.com/@uiw/react-portal)

[`Portals`](https://reactjs.org/docs/portals.html#event-bubbling-through-portals) 是 react 16 提供的官方解决方案，使得组件可以脱离父组件层级挂载在 DOM 树的任何位置，我们利用这个方法，可将模态对话框生成到根节点的外面。 

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

### 基本使用

```jsx
import { Portal } from 'uiw';

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

```

切换不同的 `<Portal />`

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

## Props

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

---
_Source: https://npm.io/package/@uiw/react-portal · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
