An open API service indexing awesome lists of open source software.

https://github.com/bring2dip/react-portal-base

React Portal for rendering modal and notifications
https://github.com/bring2dip/react-portal-base

Last synced: 5 months ago
JSON representation

React Portal for rendering modal and notifications

Awesome Lists containing this project

README

          

# React Portal Base
Simple React Portal for rendering modal and notifications

## Install

````
npm i react-portal-base
or
yarn add react-portal-base
````

## Setup
Add root element in your view.
````




````

## Example Usage
https://codesandbox.io/s/stoic-shadow-959u8

## Modal

````
import React from 'react';
import Portal from 'react-portal-base';
import ModalComponent from 'some modal';

export default ModalInPortalTest() {

return (



);
}
````

## Notifiction
Children inside notification portal disappear after `timeout` in ms. Default is `3000ms`.
````
import React from 'react';
import Portal from 'react-portal-base';
import Alert from 'some alert component';

export default ModalInPortalTest() {

return (



);
}
````

## API

````
timeout: Timeout in Number (Default 3000 ms),
portalType: One of ['modal', 'notification'] (Required)
notificationRootId: custom notification root id (Default: react-portal-base-notification-root),
modalRootId: custom notification root id (Default: react-portal-base-modal-root),
````

## License

MIT