https://github.com/react-component/portal
https://github.com/react-component/portal
Last synced: 2 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/react-component/portal
- Owner: react-component
- License: mit
- Created: 2022-09-26T13:02:29.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2025-11-26T04:00:09.000Z (about 1 month ago)
- Last Synced: 2025-11-29T05:58:03.422Z (27 days ago)
- Language: TypeScript
- Size: 54.7 KB
- Stars: 26
- Watchers: 3
- Forks: 23
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rc-portal
React 18 supported Portal Component.
[![NPM version][npm-image]][npm-url] [](https://github.com/umijs/dumi) [![build status][github-actions-image]][github-actions-url] [![Codecov][codecov-image]][codecov-url] [![npm download][download-image]][download-url]
[npm-image]: http://img.shields.io/npm/v/rc-portal.svg?style=flat-square
[npm-url]: http://npmjs.org/package/rc-portal
[github-actions-image]: https://github.com/react-component/portal/workflows/CI/badge.svg
[github-actions-url]: https://github.com/react-component/portal/actions
[codecov-image]: https://img.shields.io/codecov/c/github/react-component/portal/master.svg?style=flat-square
[codecov-url]: https://app.codecov.io/gh/react-component/portal
[download-image]: https://img.shields.io/npm/dm/rc-portal.svg?style=flat-square
[download-url]: https://npmjs.org/package/rc-portal
## Development
```bash
npm install
npm start
open http://localhost:8000
```
## Feature
- React life cycle support portal component
## Install
[](https://npmjs.org/package/rc-portal)
## Usage
```js | pure
import Portal from '@rc-component/portal';
const Demo = () => {
return Hello World;
};
export default Demo;
```
## 🔥 API
We use typescript to create the Type definition. You can view directly in IDE. But you can still check the type definition [here](https://github.com/react-component/portal/blob/master/src/interface.ts).
### Portal
| Prop | Description | Type | Default |
| ------------ | ---------------------------------- | ------------------------ | ------------- |
| getContainer | Customize portal container element | Element \| () => Element | document.body |
| open | Show the portal | boolean | false |
| autoLock | Lock screen scroll when open | boolean | false |