# react-native-portalize

> Render anything on top of the rest

Latest version **1.0.7** (published 2020-08-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-portalize
pnpm add react-native-portalize
yarn add react-native-portalize
bun add react-native-portalize
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2020-08-19 |
| First published | 2020-04-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 14.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 394 |
| Author | Jérémy Barbet |
| Maintainers | jeremy.barbet |
| Keywords | portal, react-native, react, native, ios, android, above, top |

## Links

- npm: https://www.npmjs.com/package/react-native-portalize
- Repository: https://github.com/jeremybarbet/react-native-portalize
- Homepage: https://github.com/jeremybarbet/react-native-portalize#readme
- Issues: https://github.com/jeremybarbet/react-native-portalize/issues
- npm.io page: https://npm.io/package/react-native-portalize

## 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

- 1.0.7 (latest) — 2020-08-19
- 1.0.6 — 2020-08-17
- 1.0.5 — 2020-08-11
- 1.0.4 — 2020-07-25
- 1.0.3 — 2020-04-28
- 1.0.2 — 2020-04-28
- 1.0.1 — 2020-04-24
- 1.0.0 — 2020-04-24
- 0.4.0 — 2020-04-23
- 0.3.0 — 2020-04-12
- 0.2.0 — 2020-04-12
- 0.1.0 — 2020-04-12

## README

# Portalize

[![npm version](https://badge.fury.io/js/react-native-portalize.svg)](https://badge.fury.io/js/react-native-portalize)

The simplest way to render anything on top of the rest.

This component is extracted from [`react-native-paper`](https://github.com/callstack/react-native-paper/tree/master/src/components/Portal) and has been simplified for the purpose of [`react-native-modalize`](https://github.com/jeremybarbet/react-native-modalize).

## Installation

```bash
yarn add react-native-portalize
```

## Usage

```tsx
import React from 'react';
import { View, Text } from 'react-native';
import { Host, Portal } from 'react-native-portalize';

export const MyApp = () => (
  <Host>
    <View>
      <Text>Some copy here and there...</Text>

      <Portal>
        <Text>A portal on top of the rest</Text>
      </Portal>
    </View>
  </Host>
);
```

**Example with `react-native-modalize` and `react-navigation`**

```tsx
import React from 'react';
import { View, TouchableOpacity, Text } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { Modalize } from 'react-native-modalize';
import { Host, Portal } from 'react-native-portalize';

const Tab = createBottomTabNavigator();

const ExamplesScreen = () => {
  const modalRef = useRef<Modalize>(null);

  const onOpen = () => {
    modalRef.current?.open();
  };

  return (
    <>
      <TouchableOpacity onPress={onOpen}>
        <Text>Open the modal</Text>
      </TouchableOpacity>

      <Portal>
        <Modalize ref={modalRef}>...your content</Modalize>
      </Portal>
    </>
  );
};

const SettingsScreen = () => (
  <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
    <Text>Settings screen</Text>
  </View>
);

export const App = () => (
  <NavigationContainer>
    <Host>
      <Tab.Navigator>
        <Tab.Screen name="Examples" component={ExamplesScreen} />
        <Tab.Screen name="Settings" component={SettingsScreen} />
      </Tab.Navigator>
    </Host>
  </NavigationContainer>
);
```

## Props

### Host

- `children`

A React node that will be most likely wrapping your whole app.

| Type | Required |
| ---- | -------- |
| node | Yes      |

- `style`

Optional props to define the style of the Host component.

| Type  | Required |
| ----- | -------- |
| style | No       |

### Portal

- `children`

The React node you want to display on top of the rest.

| Type | Required |
| ---- | -------- |
| node | Yes      |

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