# react-dom-portal

> React component for transportation React elements

Latest version **0.1.5** (published 2020-11-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-dom-portal
pnpm add react-dom-portal
yarn add react-dom-portal
bun add react-dom-portal
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2020-11-27 |
| First published | 2017-11-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 12 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Yakov Dalinchuk |
| Maintainers | pixd |
| Keywords | react, react-component, react-portal |

## Links

- npm: https://www.npmjs.com/package/react-dom-portal
- Repository: https://github.com/pixd/react-dom-portal
- Homepage: https://github.com/pixd/react-dom-portal#readme
- Issues: https://github.com/pixd/react-dom-portal/issues
- npm.io page: https://npm.io/package/react-dom-portal

## Dependencies (1)

- [prop-types](https://npm.io/package/prop-types.md) ^15.6.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.1.5 (latest) — 2020-11-27
- 0.1.4 — 2017-12-05
- 0.1.3 — 2017-11-28
- 0.1.2 — 2017-11-20
- 0.1.1 — 2017-11-20

## README

```javascript
import React from 'react';
import ReactDOM from 'react-dom';
import Portal from 'react-dom-portal';

const nodeFabric = () => document.createElement('section');
const node = document.createElement('section');

export default class App extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      portalIsOpen: false,
    };

    this.handleClick = this.handleClick.bind(this);
  }

  handleClick() {
    const { portalIsOpen } = this.state;
    this.setState({ portalIsOpen: !portalIsOpen });
  }

  render() {
    const { portalIsOpen } = this.state;

    return (
      <div>
        <button onClick={this.handleClick}>Click me!</button>

        {portalIsOpen
          ? (
            <Portal>
              <p>Base functionality example</p>
            </Portal>
          )
          : null}

        <Portal isContentMount={portalIsOpen}>
          <p>`isContentMount` prop example</p>
        </Portal>

        <Portal className="portal-class-name" name="portal-name">
          <p>`className` and `name` props example</p>
        </Portal>

        <Portal node="section">
          <p>`node` prop example (tag name)</p>
        </Portal>

        <Portal node={nodeFabric}>
          <p>`node` prop example (HTMLElement)</p>
        </Portal>

        <Portal node={node}>
          <p>`node` prop example (HTMLElement fabric)</p>
        </Portal>

        <Portal nodeRef={(nodeRef) => console.log(nodeRef)}>
          <p>`nodeRef` prop example</p>
        </Portal>
      </div>
    );
  }
}

ReactDOM.render(<App />, document.getElementById('root'));
```

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