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
- Host: GitHub
- URL: https://github.com/bring2dip/react-portal-base
- Owner: bring2dip
- License: mit
- Created: 2021-01-12T11:04:12.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-01-12T12:57:18.000Z (over 5 years ago)
- Last Synced: 2025-10-23T01:21:28.942Z (8 months ago)
- Language: JavaScript
- Size: 37.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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