# @dozgrou/react-native-toastr

> React Native Toastr for Android and IOS

Latest version **0.2.0** (published 2020-12-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install @dozgrou/react-native-toastr
pnpm add @dozgrou/react-native-toastr
yarn add @dozgrou/react-native-toastr
bun add @dozgrou/react-native-toastr
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2020-12-11 |
| First published | 2019-11-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 12.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | dozGrou |
| Maintainers | dozgrou |
| Keywords | react, react-native, toastr, notification, in-app |

## Links

- npm: https://www.npmjs.com/package/@dozgrou/react-native-toastr
- Repository: https://github.com/dozGrou/react-native-toastr
- Homepage: https://github.com/dozGrou/react-native-toastr#readme
- Issues: https://github.com/dozGrou/react-native-toastr/issues
- npm.io page: https://npm.io/package/@dozgrou/react-native-toastr

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2020-12-11
- 0.1.0 — 2020-09-24
- 0.0.3 — 2020-01-13
- 0.0.2 — 2019-11-23

## README

# React Native Toastr

React Native Toastr is strongly inspired by the [toastr](https://github.com/CodeSeven/toastr) package.

## Installation

```
yarn add @dozgrou/react-native-toastr
```
or
```
npm install @dozgrou/react-native-toastr
```


## Example App

To run the example application, simply clone the repository and then theses commands
```
cd example
npm install
npm run android OR npm run ios
``` 

## Usage

First, wrap your entire application with `ToastrProvider` component.

```js
import React from 'react';
import {ToastrProvider} from '@dozgrou/react-native-toastr'

class App extends React.Component {
    render() {
        return (
            <ToastrProvider>
                // App
            </ToastrProvider>
        );
    }
};
```

And then use the `withToastr` function to access the toastr api.

```jsx
import React from 'react';
import {Text, TouchableOpacity} from 'react-native';
import {withToastr} from '@dozgrou/react-native-toastr';

class Button extends React.Component {
    handlePress() {
        this.props.toastr.success('Awesome notification', {
            dismissable: false,
        });
    }
	
    render() {
        return (
            <TouchableOpacity
                onPress={() => this.handlePress()}>
                <Text>Click me</Text>
            </TouchableOpacity>
        );
    }
}

//Use the function withToastr to get access to toastr props
//in any component
export default withToastr(Button)
```

### Custom component

```jsx
import React from 'react'
import {Text, TouchableOpacity, View} from 'react-native';
import {withToastr} from '@dozgrou/react-native-toastr';

const CustomComponent = ({onRemove}) => {
  return (
    <TouchableOpacity onPress={onRemove}>
      <View>
        <Text>Awesome custom component</Text>
      </View>
    </TouchableOpacity>
  )
};

const Button = () => {
  return (
    <TouchableOpacity onPress={toastr.custom(({...config}) => <CustomComponent {...config} />)}>
      <View>Click me</View>
    </TouchableOpacity>
  );
};

export default withToastr(Button);
```

## Methods

| Method name   | Arguments                                                                         | Notes                             |
|---------------|-----------------------------------------------------------------------------------|-----------------------------------|
|success        | text: string, config?: [ToastrConfig](#toastr-config)                             | Show a success message (Green)    |
|danger         | text: string, config?: [ToastrConfig](#toastr-config)                             | Show a danger message (Red)       |
|warning        | text: string, config?: [ToastrConfig](#toastr-config)                             | Show a warning message (Yellow)   |
|info           | text: string, config?: [ToastrConfig](#toastr-config)                             | Show an info message (Blue)       |
|custom         | component: Function(onRemove: Function), config?: [ToastrConfig](#toastr-config)  | Show a custom component           |


## Toastr config
|                   | Type      | Default   | Notes                                             |
|-------------------|-----------|-----------|---------------------------------------------------|
| timeout           | boolean   | true      | Set to `false` to disable the timeout             |
| timeoutDuration   | number    | 5000      | The timeout duration in ms                        |
| dismissable       | boolean   | true      | Set to `false` to disable click to remove         |
| progressBar       | boolean   | true      | Set to `false` to deactivate the progress bar     |
| duplicate         | boolean   | true      | Set to `false` to not display duplicates toastr   |


## License
[MIT](license.md)

---
_Source: https://npm.io/package/@dozgrou/react-native-toastr · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
