@ouroboros/react-errors
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

@ouroboros/react-errors

npm version MIT License

A React component that displays error messages.

Installation

npm

npm install @ouroboros/react-errors

Using

import Errors, { addError } from '@ouroboros/react-errors';

function SomeComponent(props) {
  return (
    <div>
      <button onClick={() => addError('Test Error!')}>Add Error</button>
    </div>
  );
}

function App(props) {
  return (
    <SomeComponent />
    <Errors />
  );
}

Example image of component in use

Props

Name Type Required Description
position "bottom" | "top" no Default, "bottom"

addError

The addError function takes a string, or an object. In the case of an object the data will be JSON stringified and then displayed in a PRE elemenent to maintain the structure.

Style

You can set your own styles using the #oc_errors ID, or import / include node_modules/@ouroboros/react-errors/style.css.

Package Sidebar

Install

npm i @ouroboros/react-errors

Weekly Downloads

6

Version

1.0.1

License

MIT

Unpacked Size

23.8 kB

Total Files

10

Last publish

Collaborators

  • ouroboros