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.
react-badly
Advanced tools
Take hold of your react lifecycle hooks with react-badly
You can install off of npm with
npm install react-badly
# or yarn
yarn add react-badly
This component is a wrapper for any of your React 16+ plus components that may have an error in them.
The simplest way is to just wrap any component that you think may error with ReactBadly
This will prevent the component from rendering (also will stop any children in the tree as well). This is to make sure that your whole component tree does not dismount as React 16+ does.
import ReactBadly from 'react-badly';
// some code later on
<ReactBadly>
<SomeComponentThatMayHaveAnError>
...
</SomeComponentThatMayHaveAnError>
</ReactBadly>
If you want to handle your error with some functionality (like sending to analytics etc) you can pass an onError
property which will get the error and any info as parameters from react.
import ReactBadly from 'react-badly';
const errorFunction = (error, info) => {
// can handle the error here and do what you will with it
};
// some code later on
<ReactBadly onError={errorFunction}>
<SomeComponentThatMayHaveAnError>
...
</SomeComponentThatMayHaveAnError>
</ReactBadly>
There may also be some cases where you actually want to render something else to display if there was an error instead
of just not displaying anything. To do that you can pass the render
property which will accept a function that will
take in { error, info }
as a parameter. This will render instead of the direct child of ReactBadly
.
import ReactBadly from 'react-badly';
const renderError = ({ error, info }) => (
<React.Fragment>
<h2>You have an error!</h2>
<pre>{JSON.stringify(error)}'\n'{JSON.stringify(info)}</pre>
</React.Fragment>
);
// some code later on
<ReactBadly render={renderError}>
<SomeComponentThatMayHaveAnError>
...
</SomeComponentThatMayHaveAnError>
</ReactBadly>
FAQs
Error boundary react component
The npm package react-badly receives a total of 12 weekly downloads. As such, react-badly popularity was classified as not popular.
We found that react-badly 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.