npm.io
1.0.1 • Published 7 years ago

react-very-simple-alerts

Licence
ISC
Version
1.0.1
Deps
4
Size
47 kB
Vulns
1
Weekly
0

react-very-simple-alerts

Simple inline alerts for React

Installation

npm install react-very-simple-alerts

Ensure you have the correct peer dependencies installed:

"react": "^16.8.3",
"prop-types": "^15.7.2",
"uuid": "^3.3.2"

Usage

import React, { Fragment } from "react";
import { AlertContainer, alerts } from "react-very-simple-alerts";

const MyComponent = () => (
  <Fragment>
    <AlertContainer />

    <button onClick={() => alerts.show("Alert!")}>Show Alert!</button>
  </Fragment>
);
Usage with HOC
import React, { Fragment } from "react";
import { withAlerts } from "react-very-simple-alerts";

let WrappedComponent = ({ alerts }) => (
  <Fragment>
    <button onClick={() => alerts.show("Alert!")}>Show alert</button>
  </Fragment>
);

WrappedComponent = withAlerts(WrappedComponent);

const MyComponent = () => (
  <Fragment>
    <WrappedComponent />
  </Fragment>
);
Demo & Examples

Storybook