Skip to content

Uncaught TypeError: Cannot read properties of undefined (reading 'content') #858

@nik32

Description

@nik32

Do you want to request a feature or report a bug?
bug report

What is the current behavior?
So is complicated to explain as this might be specific to my project, But I will try!! In our product - we are having a modal on top of modal. Both of these modals are having their own ToastContainer [with multiContainer enabled and containerId provided to both - so that toast produced in one modal is not shown in the other one]. Now If after closing a toast - I 'very quickly' close the modal, I am getting the below error -
image

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your CodeSandbox (https://codesandbox.io/s/new) example below:
Steps to reproduce are given above. It will be time consuming to give the demo at the moment. But let me know if you are not able to reproduce the error with the above steps or if you really want the demo - I will try and provide a CodeSandbox.

What is the expected behavior?
The error should not occur coz it then stoped any other toasts to be displayed on the page till we refresh the page. NOTE - the first time I tested, other toasts were not being shown after the error. But in sub-sequest testing I have found that other toasts are not being stopped from displaying.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React 18 [with TS and NextJS]. I have tested on 2 browser - a. Microsoft edge on MacOS and b. safari. On both I have been able to to reproduce it with the steps told above. As edge is chromium based - i think this should also happen with chrome, don't know about firefox. On safari the following was the error [this might give you more context about this bug] -
image

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions