Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
use-browser-history
Advanced tools
A React hook to handle browser history events
https://zcallan.github.io/use-browser-history/
npm install --save use-browser-history
import React, { useState } from 'react'
import useBrowserHistory from 'use-browser-history'
function Modal({ isOpen, onClose, onOpen }) {
const [handleBack] = useBrowserHistory( 'my-modal', isOpen, onClose, onOpen );
if ( !isOpen )
return null;
return (
<div className="modal">
<div className="modal-backdrop" onClick={handleBack} />
<div className="modal-box">
<p>Hello!</p>
<button onClick={handleBack}>Close modal</button>
</div>
</div>
)
}
function App() {
const [isOpen, setIsOpen] = useState( false );
return (
<div>
<button onClick={() => setIsOpen( true )}>Open modal</button>
<Modal
isOpen={isOpen}
onClose={() => setIsOpen( false )}
onOpen={() => setIsOpen( true )}
/>
</div>
);
}
const [handleBack, handleForward] = useBrowserHistory( name, isActive, onBack, onForward );
Key | Type | Description |
---|---|---|
name | string | (required) The unique name to be used inside the browser history state. |
isActive | bool | (required) Whether or not the entry should exist in the browser history state. For example, in the case of a modal, this should be set to true when the modal is open / visible, and false when it's closed. |
onBack | func | A callback that is fired when the back button is pressed, or when the handleBack (first arg returned by useBrowserHistory ) function is called and the browser history state has been cleaned up. |
onForward | func | Exactly like onBack , but for the forward button. You can use this to re-perform something if the user clicks back then forward (like in the example GIF above), to do something such as re-opening a modal. |
MIT © zcallan
FAQs
> A React hook to handle browser history events
The npm package use-browser-history receives a total of 0 weekly downloads. As such, use-browser-history popularity was classified as not popular.
We found that use-browser-history demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.