react-snack

0.0.1 • Public • Published

react-snack

Snacks, lots of them

NPM JavaScript Style Guide

Snackbar like notifications for react. Completely customizable but with batteries included!

Install

yarn add react-snack

Usage

React-snack uses the React.Context API introduced in React 16.3.

First Wrap your app in a SnackProvider

import { SnackProvider } from 'react-snack'
 
ReactDOM.render(<SnackProvider><App /></SnackProvider>, document.getElementById('root'))

Then simply use the SnackConsumer to add messages to the snack bar anywhere in your app:

import { SnackConsumer } from 'react-snack'
 
...
render() {
  return <SnackConsumer>
    {({ addMessage }) => (
      <button onClick={() => addMessage({
        title: 'A message',
        message: 'With a bunch of text',
        type: 'SUCCESS'
      })}>Add Notification</button>
    )}
  </SnackConsumer>
}

License

MIT © juliankrispel

Readme

Keywords

none

Package Sidebar

Install

npm i react-snack

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

93.9 kB

Total Files

6

Last publish

Collaborators

  • juliankrispel