react-error-decoder
TypeScript icon, indicating that this package has built-in type declarations

2.0.6 • Public • Published

react-error-decoder

⚛︎ Decode react minified error message

In the minified production build of React, they avoid sending down full error messages. Instead, we can use the error code to view the full message for full errors and additional helpful warnings.

This small tool is meant to mitigate this gap.

import { decode } from "react-error-decoder";

decode(
  "Minified React error #130; visit https://reactjs.org/docs/error-decoder.html?invariant=130&args[]=undefined&args[]= for the full message or use the non-minified dev environment for full errors and additional helpful warnings.",
);

// Output:
("Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.");

Safe for any error message

decode("Something must have gone horribly wrong");

// Output:
("Something must have gone horribly wrong");

Get some more details

decode.details('Minified React error #130; visit https://reactjs.org/docs/error-decoder.html?invariant=130&args[]=undefined&args[]= for the full message or use the non-minified dev environment for full errors and additional helpful warnings.')

// Output:
{
  message: 'Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.',
  invariant: '130',
  url: 'https://reactjs.org/docs/error-decoder.html?invariant=130&args[]=undefined&args[]='
}

// non react object
{
  message: 'Something must have gone horribly wrong',
  invariant: undefined,
  url: undefined
}

Uses source list from React repo

Package Sidebar

Install

npm i react-error-decoder

Weekly Downloads

213

Version

2.0.6

License

Unlicense

Unpacked Size

117 kB

Total Files

6

Last publish

Collaborators

  • omrilotan