Exciting release!Introducing "safe npm". Learn more
Socket
Log inDemoInstall

@evo/errcatch

Package Overview
Dependencies
0
Maintainers
14
Versions
9
Issues
File Explorer

Advanced tools

@evo/errcatch

Catch react errors

    1.0.7latest
    npm

Version published
Maintainers
14
Weekly downloads
441
decreased by-52.88%

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 installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket
support@socket.devSocket SOC 2 Logo

Product

  • Package Issues
  • 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