Skip to content

Commit

Permalink
support custom id for toast
Browse files Browse the repository at this point in the history
  • Loading branch information
arnnis committed Dec 12, 2020
1 parent e5099ba commit 721c347
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"react": "~16.11.0",
"react-dom": "~16.11.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz",
"react-native-fast-toast": "^2.1.3",
"react-native-fast-toast": "../",
"react-native-web": "~0.11.7"
},
"devDependencies": {
Expand Down
4 changes: 1 addition & 3 deletions example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4397,10 +4397,8 @@ react-native-appearance@~0.3.3:
invariant "^2.2.4"
use-subscription "^1.0.0"

react-native-fast-toast@^2.1.3:
react-native-fast-toast@../:
version "2.1.3"
resolved "https://registry.yarnpkg.com/react-native-fast-toast/-/react-native-fast-toast-2.1.3.tgz#26a843bd5fd21b7c61f027682d0ec6d642c1a80d"
integrity sha512-4bpMlHw3lrhfxWhvEq69XhYeFm5/KhGbK0wPNTUS2dniKVqrJyr8ySAGP+qbU34E65KTxX4hQOTICo+fdqQICQ==

react-native-safe-area-context@~3.0.7:
version "3.0.7"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-fast-toast",
"version": "2.1.3",
"version": "2.1.4",
"main": "lib/commonjs/index.js",
"module": "lib/module/index.js",
"types": "lib/typescript/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/toast-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ToastContainer extends Component<Props, State> {
};

show = (message: string | JSX.Element, toastOptions?: ToastOptions) => {
let id = Math.random().toString();
let id = toastOptions?.id || Math.random().toString();
const onClose = () => this.hide(id);

requestAnimationFrame(() => {
Expand Down
1 change: 1 addition & 0 deletions src/toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from "react-native";

export interface ToastOptions {
id?: string;
icon?: JSX.Element;
type?: "normal" | "success" | "danger" | "warning";
duration?: number;
Expand Down

0 comments on commit 721c347

Please sign in to comment.