react-toastify icon indicating copy to clipboard operation
react-toastify copied to clipboard

Cannot read properties of undefined (reading 'props') at deleteToast

Open jeymus opened this issue 1 year ago • 8 comments

:bug:Bug

TypeError: Cannot read properties of undefined (reading 'props') at deleteToast in withTranslation.js

This error appears on v10.0.0 and above, and is triggered when the toast is dismissed immediately after rendering. This is a similar issue to one that was previously fixed in v9.1.3 but it has now appeared again. I have tested on v9.1.3 with no issues. v9.1.3's release note:

Partially address Toast is undefined || Uncaught TypeError: Cannot read properties of undefined (reading 'content') #858 #952

Basic example:

const handleClick = async (e) => {
    const toastId = toast.loading('Loading')
    try {
        return console.log('Test log')
    }
    catch (error) {
        console.error(error)
    }
    finally {
        toast.dismiss(toastId)
    }
}

jeymus avatar Jan 29 '24 05:01 jeymus

Any solution on this? I'm facing the same problem

duythinh-dev avatar Apr 19 '24 05:04 duythinh-dev

Same issue here

arenier avatar Jun 07 '24 09:06 arenier

Same

gajraj-gan avatar Jun 13 '24 12:06 gajraj-gan

same issue here

abdullahhjiim avatar Jun 19 '24 12:06 abdullahhjiim

same

dolev7 avatar Jun 24 '24 11:06 dolev7

bump

bhimeshchauhan avatar Jul 03 '24 00:07 bhimeshchauhan

wherever in your code you want to manually close the toast just put this code(mine worked) -

if (toast.isActive(null)) { // Check if any toast is active
    toast.dismiss();
} else {
    console.warn("Toast not found for dismissal");
}

Souvik2003K avatar Jul 04 '24 03:07 Souvik2003K

For me, the issue was:

  • There were multiple toasts being created in the container
    • Adding enableMultiContainer and containerId="<unique-id>" helped
  • The toast was being closed before it opened
    • Adding timeout to close, helped

bhimeshchauhan avatar Jul 04 '24 14:07 bhimeshchauhan