Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
babel-plugin-react-error-catcher
Advanced tools
Automatically adds a decorator to React components. Accepts a single argument, a path to some module for error reporting, and if there's an error, it will catch it and pass it to the reporter.
Feel free to try to break this, submit issues and pull requests, and/or request features!
Automatically adds a decorator to React components. Accepts a single argument, a path to some module for error reporting, and if there's an error, it will catch it and pass it to the reporter. The reporter can be either of the following:
Props/Arguments:
jspm install babel-plugin-react-error-catcher=github:loggur/babel-plugin-react-error-catcher
or
jspm install npm:babel-plugin-react-error-catcher
or
npm install babel-plugin-react-error-catcher
There's not much to it, really. All you do is provide the plugin to Babel with the path to a reporter module. Use whatever reporter you want, or try out one of the three included:
Component that displays the error string with white text on a red background
Function that uses the component from #2 but ensures it's the same size as the originating component
Note: The reporter may also export a rendered
function that you can use to obtain information about components as soon as they've successfully rendered. See same-size-reporter
for an example.
From examples/jspm/client/minimal-editor.js
:
import hotPlugin from 'babel-plugin-react-hot';
import errorCatcher from 'babel-plugin-react-error-catcher';
const reportersDir = 'babel-plugin-react-error-catcher/reporters/';
const reporterPath = reportersDir+'same-size-reporter';
System.config({
"trace": true,
"babelOptions": {
"stage": 0,
"optional": [
"runtime"
],
"plugins": [
hotPlugin,
errorCatcher(reporterPath)
]
}
});
That's it! Try it yourself:
Note: NPM likes to timeout sometimes when downloading packages, so if this happens, just keep trying
npm install
andnpm run jspm-install
beforenpm start
.
git clone git@github.com:loggur/babel-plugin-react-error-catcher.git
cd babel-plugin-react-error-catcher/examples/jspm
npm install
npm run jspm-install
npm start
open http://localhost:8080
{
"stage": 0,
"optional": [
"runtime"
],
"plugins": [
"react-hot",
"./error-catcher"
]
}
examples/webpack/error-catcher.js
:
var catcherPath = 'babel-plugin-react-error-catcher';
var reporterPath = catcherPath+'/reporters/same-size-reporter';
module.exports = require(catcherPath)(reporterPath);
That's it! Try it yourself:
Note: NPM likes to timeout sometimes when downloading packages, so if this happens, just keep trying
npm install
beforenpm start
.
git clone git@github.com:loggur/babel-plugin-react-error-catcher.git
cd babel-plugin-react-error-catcher/examples/webpack
npm install
npm start
open http://localhost:8080
This is currently used within branches
(extensive work-in-progress) and it is designed to work with React hot reloading. See babel-plugin-react-hot
for said Babel plugin.
MIT
FAQs
Automatically adds a decorator to React components. Accepts a single argument, a path to some module for error reporting, and if there's an error, it will catch it and pass it to the reporter.
The npm package babel-plugin-react-error-catcher receives a total of 14 weekly downloads. As such, babel-plugin-react-error-catcher popularity was classified as not popular.
We found that babel-plugin-react-error-catcher 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.