# react-native-root-portal

> React portal support for react-native based on react-native-root-siblings, components for modals, toasts, loading indicators, cover layers...

Latest version **1.0.9** (published 2021-02-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-root-portal
pnpm add react-native-root-portal
yarn add react-native-root-portal
bun add react-native-root-portal
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.9 |
| Published | 2021-02-04 |
| First published | 2019-11-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 15.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Horcrux |
| Maintainers | magicismight |
| Keywords | react-native, portal, gateway, modal, cover |

## Links

- npm: https://www.npmjs.com/package/react-native-root-portal
- Repository: https://github.com/magicismight/react-native-root-portal
- Issues: https://github.com/magicismight/react-native-root-portal/issues
- npm.io page: https://npm.io/package/react-native-root-portal

## Dependencies (1)

- [react-native-root-siblings](https://npm.io/package/react-native-root-siblings.md) ^4.0.3

## Alternatives

- [react-native-root-siblings](https://npm.io/package/react-native-root-siblings.md) — 102.9K weekly downloads
- [@praxisui/dialog](https://npm.io/package/@praxisui/dialog.md) — 2.0K weekly downloads
- [easy-toggle-state](https://npm.io/package/easy-toggle-state.md) — 350 weekly downloads
- [ngx-lightbox-evp](https://npm.io/package/ngx-lightbox-evp.md) — 19 weekly downloads
- [react-native-modal-translucent-axton](https://npm.io/package/react-native-modal-translucent-axton.md) — 4 weekly downloads

## Recent versions

- 1.0.9 (latest) — 2021-02-04
- 0.0.1-beta.9 (next) — 2019-11-14
- 0.0.0 — 2020-12-08
- 1.0.8 — 2020-11-25
- 1.0.7 — 2020-11-18
- 1.0.6 — 2020-11-11
- 1.0.5 — 2020-04-01
- 1.0.4 — 2020-04-01
- 1.0.3 — 2019-12-25
- 1.0.2 — 2019-12-11
- 1.0.1 — 2019-11-20
- 1.0.0 — 2019-11-20
- 0.0.1-beta.8 — 2019-11-13
- 0.0.1-beta.7 — 2019-11-13
- 0.0.1-beta.6 — 2019-11-13
- … 5 more at https://npm.io/package/react-native-root-portal/versions

## README

# react-native-root-portal

React portal support for react-native based on react-native-root-siblings.
Can create components for modals, toasts, loading bars, cover layers etc. to anywhere in your project.

## Installation

```
npm i react-native-root-portal
```
OR

```
yarn add react-native-root-portal
```

## Usage

### Portal.Exit

Create a way out for the react nodes put in a `Portal.Entry`

```
import Portal from 'react-native-root-portal';

function ExitDemo(props) {
  return (
    <>
      <OneOfYourComponent />
      {/* React nodes those put in a `Portal.Entry` named `portkey` will transport to here */}
      <Portal.Exit name={'portkey'} />
    </>
  );
}

```

### Portal.Entry

Put react nodes into the children, and transport them to the `Portal.Exit`.

```
import { StyleSheet, View } from 'react-native';
import Portal from 'react-native-root-portal';

function EntryDemo(props) {
  return (
    <Portal.Entry target={'portkey'}>
      <View style={[StyleSheet.absoluteFill, { backgroundColor: 'rgba(0, 0, 0, 0.4)' }]} />
    </Portal.Entry>
  );
}
```

### Portal.enter

Transport a react node outside react lifecycle.

```
import Portal from 'react-native-root-portal';

setTimeout(() => {
  Portal.enter(
    'portkey',
    <View style={[StyleSheet.absoluteFill, { backgroundColor: 'rgba(0, 0, 0, 0.4)' }]} />,
    () => {
      console.log('Rendered');
    }
  );
}, 2000);

```

### Portal.isExisted

Check if the name for Portal.Exit is existed in the project, in case of conflicts.

```
import Portal from 'react-native-root-portal';

// If a Portal.Exit has been rendered in the project it will return `true`
console.log(Portal.isExisted('portkey'));

```

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