Skip to content

ouroboroscoding/react-errors

Repository files navigation

@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.

About

Errors Component

Resources

License

Stars

Watchers

Forks

Packages

No packages published