Skip to content
This repository has been archived by the owner on Jul 24, 2023. It is now read-only.

Commit

Permalink
feat(Toast): pass options through, disable autoClose for error
Browse files Browse the repository at this point in the history
  • Loading branch information
CanRau committed Oct 6, 2018
1 parent 7bdd760 commit 056fad2
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions src/utils/toast.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
import { toast as toastify } from 'react-toastify'
import { toast as T } from 'react-toastify'

export const toast = message =>
toastify(message, {
type: toastify.TYPE.DEFAULT,
export const toast = (message, opts) =>
T(message, {
...opts,
type: T.TYPE.DEFAULT,
})

toast.info = message =>
toastify(message, {
type: toastify.TYPE.INFO,
toast.info = (message, opts) =>
T(message, {
...opts,
type: T.TYPE.INFO,
})

toast.success = message =>
toastify(message, {
type: toastify.TYPE.SUCCESS,
toast.success = (message, opts) =>
T(message, {
...opts,
type: T.TYPE.SUCCESS,
})

toast.warning = message =>
toastify(message, {
type: toastify.TYPE.WARNING,
toast.warning = (message, opts) =>
T(message, {
...opts,
type: T.TYPE.WARNING,
})

toast.error = message =>
toastify(message, {
type: toastify.TYPE.ERROR,
toast.error = (message, opts) =>
T(message, {
autoClose: 25000,
...opts,
type: T.TYPE.ERROR,
})

0 comments on commit 056fad2

Please sign in to comment.