v9.1.0
Release notes
π Features
toast.promise
let you typedata
for each state. This is useful when rendering something based on the response.
For example:
interface Success {
username: string
}
interface Error {
err: string
}
toast.promise<Success,Error>(myPromise, {
success: {
render({ data }) {
return data.username;
}
},
error: {
render({ data }) {
return data.err;
}
}
})
toast.update
accepts a generic as well to specify the data type
interface TData {
username: string
}
toast.update<TData>(id, {
data: payload,
render({ data }) {
return `hello ${data.username}`
}
})
π· Bugfixes
- fix progress countdown stops on mobile #580
- prevent clash with ios native gesture #397
- fix toast when a word is too long #864
- fix missing types declarations in exports #843
- fix
toast.done
not dismissing toast #853 - fix cursor when close on click is false #839
π¨ Deprecated API
Added deprecation notice for the API below. They will be removed in the next major release
API | Why | Alternative |
---|---|---|
onClick |
Not used that much, it's increasing the API surface for nothing | Can easily be implemented in userland. Just render a react component and attach the handler to it. toast(<div onClick={doSomething}>hello</div>) |
onOpen |
Does not play well with useEffect behavior in react18 (runs twice in dev mode) see #741 |
A better approach is to use toast.onChange see https://fkhadra.github.io/react-toastify/listen-for-changes/ |
onClose |
Does not play well with useEffect behavior in react18 (runs twice in dev mode) see #741 |
A better approach is to use toast.onChange see https://fkhadra.github.io/react-toastify/listen-for-changes/ |
toast.POSITION |
Reduce bundle size :) | Thanks to typescript, we now have autocomplete |
toast.TYPE |
Reduce bundle size :) | Thanks to typescript, we now have autocomplete |
βοΈ Chore
- bump dependencies
- refactor internal