1.0.1 • Published 5 years ago

react-very-simple-alerts v1.0.1

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

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