Skip to main content

Custom Toast component

This is list of props your custom toast component will receive:

PropertyTypeDescription
idstringID of toast
namestringName of target this toast is attached to
removeMeFunction () => voidCall this to remove current toast
placement'top' | 'right' | 'bottom' | 'left'Placement of current toast. Might be useful to figure out which animation to use
dataTData you passed to addToast function
animationObjectContains data which might be handy for animating toast
animation.state"entering" | "entered" | "exiting" | "exited" | "unmounted"State of toast. You probably want to enable animation when toast in entering or/and exiting state
animation.durationnumberDuration of animation from provider
animation.disableTransitionsbooleanThis will be true for renders where react-local-toast changes toast position (e.g. toast size changed and now requires repositioning) which shouldn't be transitioned (in opposition to positioan changes that you probably want to animate, like moving toast closer to target once previous toast was removed). Since if you enable transition and change elements position in same tick – position change will be animated, I'd recommend to postpone enabling transition for next render (see example in default-implementation.tsx)