Socket
Socket
Sign inDemoInstall

@evo/errcatch

Package Overview
Dependencies
5
Maintainers
14
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @evo/errcatch

Catch react errors


Version published
Weekly downloads
751
decreased by-6.01%
Maintainers
14
Install size
8.02 kB
Created
Weekly downloads
 

Readme

Source

ErrCatch

npm - https://www.npmjs.com/package/@evo/errcatch

Небольшой компонент вокруг error boundary API - https://reactjs.org/docs/error-boundaries.html.

Фичи:

  • В деве будет подсвечивать "упавший" компонент красным. На проде по умолчанию ничего не рендерит.
  • Можно задать логирование ошибок в 1 месте (на бекенде через syslog, на фронте через gotcha).
  • Есть возможность рендерить кастомный компонент при ошибке.

Установка

npm i @evo/errcatch

Пример:

import { ErrCatch, withErrCatch } from '@evo/errcatch'

const Component = () => (
    <div>
        <Component1/>
        <ErrCatch>
            <Component1/>
        </ErrCatch>
    </div>
);

// or HOC
const Component = withErrCatch(() => (
    <div>
        <Component1/>
    </div>
));

Логирование ошибок (gotcha,logevo e.t.c)

import { setErrCatchLog } from '@evo/errcatch';
import * as gotcha from '@evo/gotcha-log';

setErrCatchLog((msg, error, info) => {
    console.error(msg, error, info);
    gotcha.error(msg, { message: error.message, stack: error.stack });
});

Custom Error компонент

import { ErrCatch } from '@evo/errcatch'

const ErrorComponent = () => <div>Error</div>

const Component = () => (
    <div>
        <Component1/>
        <ErrCatch errorComponent={<ErrorComponent/>}>
            <Component1/>
        </ErrCatch>
    </div>
);

FAQs

Last updated on 25 Oct 2022

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc