0.0.1 • Published 6 years ago

react-snack v0.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

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