1.0.0 • Published 10 months ago

@remyar/react-snackbar v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

react-snackbar

Snackbar provider for react

Installation

This library was built with React >=18 in mind. It might work on lower versions as well, but the lib is developed for and tested on those versions.

npm install @remyar/react-snackbar --save

Usage

The lib exposes the following methods:

SnackbarProvider

import { StoreProvider } from '@remyar/react-snackbar';
...

 root.render(
        <React.Fragment>
            <SnackbarProvider>
                 <App /> --> Your Application
            </SnackbarProvider>
        </React.Fragment>
    );

withSnackBar

import { withSnackBar } from '@remyar/react-snackbar';
...

function YourReactComponent(props) {
    
    return <div>
        <MenuItem onClick={() => {
                props.snackbar.error("error text");
            }}>
        </MenuItem>
        <MenuItem onClick={() => {
                props.warning.warning("warning text");
            }}>
        </MenuItem>
        <MenuItem onClick={() => {
                props.warning.success("success text");
            }}>
        </MenuItem>
        <MenuItem onClick={() => {
                props.info.error("info text");
            }}>
        </MenuItem>
        </div>
}

export default withStoreProvider(YourReactComponent);
1.0.0

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago