Gathering detailed insights and metrics for react-useportal-test
Gathering detailed insights and metrics for react-useportal-test
Gathering detailed insights and metrics for react-useportal-test
Gathering detailed insights and metrics for react-useportal-test
npm install react-useportal-test
Typescript
Module System
67.1
Supply Chain
97.7
Quality
74.9
Maintenance
100
Vulnerability
100
License
TypeScript (90.62%)
JavaScript (9.38%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
888 Stars
216 Commits
34 Forks
6 Watchers
125 Branches
8 Contributors
Updated on Jul 05, 2025
Latest Version
0.1.40
Package Id
react-useportal-test@0.1.40
Unpacked Size
432.00 kB
Size
377.93 kB
File Count
14
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
3
🌀 React hook for using Portals
Need to make dropdowns, lightboxes/modals/dialogs, global message notifications, or tooltips in React? React Portals provide a first-class way to render children into a DOM node that exists outside the DOM hierarchy of the parent component (react docs).
1yarn add react react-dom react-useportal
1import usePortal from 'react-useportal' 2 3<Portal> 4 This text is portaled at the end of document.body! 5</Portal> 6 7<Portal bindTo={document && document.getElementById('san-francisco')}> 8 This text is portaled into San Francisco! 9</Portal>
1import usePortal from 'react-useportal' 2 3const App = () => { 4 var { openPortal, closePortal, isOpen, Portal } = usePortal() 5 6 // want to use array destructuring? You can do that too 7 var [openPortal, closePortal, isOpen, Portal] = usePortal() 8 9 return ( 10 <> 11 <button onClick={openPortal}> 12 Open Portal 13 </button> 14 {isOpen && ( 15 <Portal> 16 <p> 17 This Portal handles its own state.{' '} 18 <button onClick={closePortal}>Close me!</button>, hit ESC or 19 click outside of me. 20 </p> 21 </Portal> 22 )} 23 </> 24 ) 25}
1import usePortal from 'react-useportal' 2 3const App = () => { 4 const { openPortal, closePortal, isOpen, Portal } = usePortal() 5 return ( 6 <> 7 <button onClick={openPortal}> 8 Open Portal 9 </button> 10 <Portal> 11 <p className={isOpen ? 'animateIn' : 'animateOut'}> 12 This Portal handles its own state.{' '} 13 <button onClick={closePortal}>Close me!</button>, hit ESC or 14 click outside of me. 15 </p> 16 </Portal> 17 </> 18 ) 19}
Make sure you are passing the html synthetic event to the openPortal
. i.e. onClick={e => openPortal(e)}
Option | Description |
---|---|
closeOnOutsideClick | This will close the portal when not clicking within the portal. Default is true |
closeOnEsc | This will allow you to hit ESC and it will close the modal. Default is true |
renderBelowClickedElement | This will put the portal right under the element that you click on. Great for dropdowns. Required to pass event to openPortal onClick={event => openPortal(event)} |
bindTo | This is the DOM node you want to attach the portal to. By default it attaches to document.body |
isOpen | This will be the default for the portal. Default is false |
1const {
2 openPortal,
3 closePortal,
4 togglePortal,
5 isOpen,
6 Portal
7} = usePortal({
8 closeOnOutsideClick: true,
9 closeOnEsc: true,
10 renderBelowClickedElement, // appear directly under the clicked element/node in the DOM
11 bindTo, // attach the portal to this node in the DOM
12 isOpen: false,
13})
1 const { openPortal, closePortal, isOpen, Portal } = usePortal({ 2 popup: ['', '', 'width=600,height=400,left=200,top=200'] 3 }) 4 // window.open('', '', 'width=600,height=400,left=200,top=200')
[openPortal, closePortal, ..., Portal] = usePortal()
and like current object destructuringNo vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 7/13 approved changesets -- score normalized to 5
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
85 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-14
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More