Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
use-react-router
Advanced tools
useReactRouter
is a React Hook that provides pub-sub behavior for react-router
.
Unlike the withRouter
Higher-Order Component, useReactRouter
will re-render your component when the location changes!
useReactRouter()
returns an object that contains the history
, location
, and match
properties that would be passed as props by the HOC.
A tutorial covering the design and development of this package can be found on Medium: How to Convert withRouter to a React Hook.
Pub-sub behavior is a common request (that's commonly rejected) for the react-router
package.
For users who adamently prefer pub-sub behavior over react-router
's suggested alternatives, this package offers a solution.
A non-pub-sub React Hook is anticipated to eventually be included in the react-router
package itself.
You must be using react-router
and react-router-dom
v5.0.0 or greater.
npm install use-react-router
oryarn add use-react-router
Import useReactRouter
and use it as a React Hook.
import useReactRouter from 'use-react-router';
const MyPath = () => {
const { history, location, match } = useReactRouter();
return (
<div>
My location is {location.pathname}!
</div>
);
};
FAQs
React Hook for pub-sub behavior using React Router.
We found that use-react-router 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.