react-hot-toast icon indicating copy to clipboard operation
react-hot-toast copied to clipboard

Add ability to customise default toast messages

Open tobiasbueschel opened this issue 4 years ago • 0 comments

Hi @timolins 👋

I was thinking that the following API would be nice to allow users to default to a certain toast message if none is provided:

// example API
<Toaster types=[{
  icon: ErrorIcon,
  defaultMessage: 'An error happened'
}]

// in this way one could do the following
toast.error()

// An alternative to this would be to wrap the `toast` object and export it in your application, e.g.
import { toast as toastHander } from 'react-hot-toast'

export const toast = {
  ...toastHandler,
  error: (message, opts) => toastHandler.error(message || 'Your default error message', opts)
}

What do you think?

tobiasbueschel avatar Feb 09 '21 15:02 tobiasbueschel