{"id":3995,"url":"https://github.com/crazycodeboy/react-native-easy-toast","last_synced_at":"2025-05-14T18:07:22.722Z","repository":{"id":10842724,"uuid":"67208804","full_name":"crazycodeboy/react-native-easy-toast","owner":"crazycodeboy","description":"A react native module to show toast like android, it works on iOS and Android.","archived":false,"fork":false,"pushed_at":"2024-04-25T07:56:51.000Z","size":983,"stargazers_count":1141,"open_issues_count":85,"forks_count":261,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-05-14T07:10:21.437Z","etag":null,"topics":["react-native","react-native-toast","react-toast","toast"],"latest_commit_sha":null,"homepage":"http://www.devio.org/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/crazycodeboy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-02T09:14:42.000Z","updated_at":"2025-05-10T15:39:51.000Z","dependencies_parsed_at":"2024-06-18T12:25:05.432Z","dependency_job_id":"21178991-77a7-4aaf-af35-f829b6f25b0c","html_url":"https://github.com/crazycodeboy/react-native-easy-toast","commit_stats":{"total_commits":51,"total_committers":21,"mean_commits":"2.4285714285714284","dds":0.6666666666666667,"last_synced_commit":"a5639372651be9246d5c5504e0a333e3e3f832aa"},"previous_names":["crazycodeboy/react-native-toast-easy"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crazycodeboy%2Freact-native-easy-toast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crazycodeboy%2Freact-native-easy-toast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crazycodeboy%2Freact-native-easy-toast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crazycodeboy%2Freact-native-easy-toast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crazycodeboy","download_url":"https://codeload.github.com/crazycodeboy/react-native-easy-toast/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254123671,"owners_count":22018616,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["react-native","react-native-toast","react-toast","toast"],"created_at":"2024-01-05T20:16:57.950Z","updated_at":"2025-05-14T18:07:17.714Z","avatar_url":"https://github.com/crazycodeboy.png","language":"JavaScript","readme":"# react-native-easy-toast\nA react native module to show toast like android, it works on iOS and Android.\n\n[ ![release](https://img.shields.io/github/release/crazycodeboy/react-native-easy-toast.svg?maxAge=2592000?style=flat-square)](https://github.com/crazycodeboy/react-native-easy-toast/releases)\n[ ![PRs Welcome](https://img.shields.io/badge/PRs-Welcome-brightgreen.svg)](https://github.com/crazycodeboy/react-native-easy-toast/pulls)\n[ ![NPM version](http://img.shields.io/npm/v/react-native-easy-toast.svg?style=flat)](https://www.npmjs.com/package/react-native-easy-toast)\n[![License MIT](http://img.shields.io/badge/license-MIT-orange.svg?style=flat)](https://raw.githubusercontent.com/crazycodeboy/react-native-easy-toast/master/LICENSE)\n[ ![语言 中文](https://img.shields.io/badge/语言-中文-yellow.svg)](https://github.com/crazycodeboy/react-native-easy-toast/blob/master/README.zh.md)\n\n## Content\n\n- [Installation](#installation)\n- [Demo](#demo)\n- [Getting started](#getting-started)\n- [API](#api)\n- [Contribution](#contribution)\n\n## Installation\n\n* 1.Run `npm i react-native-easy-toast --save`\n  * or  `yarn add react-native-easy-toast`\n* 2.`import Toast, {DURATION} from 'react-native-easy-toast'`\n\n## Demo\n* [Examples](https://github.com/crazycodeboy/react-native-easy-toast/tree/master/examples)\n\n![Screenshots](https://raw.githubusercontent.com/crazycodeboy/react-native-easy-toast/master/examples/Screenshots/react-native-easy-toast-screenshots.gif)\n\n## Getting started\n\nAdd `react-native-easy-toast` to your js file.\n\n`import Toast, {DURATION} from 'react-native-easy-toast'`\n\nInside your component's render method, use Toast:\n\n```javascript\n render() {\n     return (\n         \u003cView\u003e\n             ...\n            \u003cToast ref={(toast) =\u003e this.toast = toast}/\u003e\n         \u003c/View\u003e\n     );\n }\n```\n\n\u003e\u003cspan style=\"color:red\"\u003eNote: Be sure to add `Toast` to the bottom of the root view.\u003c/span\u003e\n\n\nThen you can use it like this:\n\n```javascript\nthis.toast.show('hello world!');\n```\n\nThat's it, you're ready to go!\n\nshow a toast, and execute callback function when toast close it:\n\n```javascript\nthis.toast.show('hello world!', 500, () =\u003e {\n    // something you want to do at close\n});\n```\n\nShow a toast forever until you manually close it:\n\n```javascript\nthis.toast.show('hello world!', DURATION.FOREVER);\n```\n\nOr pass an element:\n\n```javascript\nthis.toast.show(\u003cView\u003e\u003cText\u003ehello world!\u003c/Text\u003e\u003c/View\u003e);\n // later on:\n this.toast.close('hello world!');\n```\n\nOptional you can pass a delay in seconds to the close()-method:\n\n```javascript\n this.toast.close('hello world!', 500);\n```\n\nCurrently, the default delay for close() in FOREVER-mode is set to 250 ms (or this.props.defaultCloseDelay, which you can pass with)\n\n```jsx\n \u003cToast ... defaultCloseDelay={100} /\u003e\n```\n\n\n\n### Basic usage\n\n```javascript\nrender() {\nreturn (\n    \u003cView\u003e\n        \u003cButton title={'Press me'} onPress={()=\u003e{\n            this.toast.show('hello world!',2000);\n        }}/\u003e\n        \u003cToast ref={(toast) =\u003e this.toast = toast}/\u003e\n    \u003c/View\u003e\n);\n    }\n```\n\n### Custom Toast\n\n```javascript\nrender() {\n    return (\n        \u003cView\u003e\n            \u003cButton title={'Press me'} onPress={()=\u003e{\n                    this.toast.show('hello world!',2000);\n                }}/\u003e\n            \u003cToast\n                ref={(toast) =\u003e this.toast = toast}\n                style={{backgroundColor:'red'}}\n                position='top'\n                positionValue={200}\n                fadeInDuration={750}\n                fadeOutDuration={1000}\n                opacity={0.8}\n                textStyle={{color:'red'}}\n            /\u003e\n        \u003c/View\u003e\n    );\n}\n```\n\n**More Usage:**\n\n[GitHubPopular](https://github.com/crazycodeboy/GitHubPopular/blob/develop/js/page/SearchPage.js)\n\n\n\n## API\n\n\nProps              | Type     | Optional | Default     | Description\n----------------- | -------- | -------- | ----------- | -----------\nstyle  | View.propTypes.style  | true | {backgroundColor: 'black',opacity: OPACITY,borderRadius: 5,padding: 10,}  |   Custom style toast\nposition |  PropTypes.oneOf(['top','center','bottom',]) |true | 'bottom'  | Custom toast position\npositionValue  | React.PropTypes.number  | true | 120  |   Custom toast position value\nfadeInDuration  | React.PropTypes.number  | true | 500  |   Custom toast show duration\nfadeOutDuration  | React.PropTypes.number  | true | 500  |   Custom toast close duration\nopacity  | React.PropTypes.number  | true | 1  |   Custom toast opacity\ntextStyle  | View.propTypes.style  | true | {color:'white'}  |   Custom style text\n\n\n\nMethod   |  Type     | Optional | Description\n----------------- | -------- | -------- | -----------\nshow(text, duration, callback, onPress)   | function | false | show a toast,unit is millisecond，and do callback\nclose()  |   function  |  -   |   start the close timer\n\n\n## Contribution\n\nIssues are welcome. Please add a screenshot of bug and code snippet. Quickest way to solve issue is to reproduce it on one of the examples.\n\nPull requests are welcome. If you want to change API or making something big better to create issue and discuss it first.\n\n---\n\n**MIT Licensed**\n","funding_links":[],"categories":["Components","组件","Others"],"sub_categories":["UI","弹框"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrazycodeboy%2Freact-native-easy-toast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrazycodeboy%2Freact-native-easy-toast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrazycodeboy%2Freact-native-easy-toast/lists"}