react-toastify
react-toastify copied to clipboard
Cannot read properties of undefined (reading 'props') at deleteToast
: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)
}
}
Any solution on this? I'm facing the same problem
Same issue here
Same
same issue here
same
bump
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");
}
For me, the issue was:
- There were multiple toasts being created in the container
- Adding
enableMultiContainer
andcontainerId="<unique-id>"
helped
- Adding
- The toast was being closed before it opened
- Adding timeout to close, helped