I am trying to show the error component (custom made component) in React JS when a error will occur after clicking a button. This component has a timeout of 2000 ms and after that it will fade away. But if I click the button multiple times the error component is coming multiple times and waiting for 2 seconds.
Now what I want is if I know that the error component is already mounted, then using a simple if-else condition I can handle the scenario.
So I want to know how to know if a particular component is mounted in React.
The error component has a default timeout that is 4 second. So when I click the button the Error component is appeared and waiting for 4 seconds to complete. Now in 4 seconds if I click again the button, then previously mounted error component is unmounted but still stays on the top of the screen. A new error component with same data appears on the top of the screen. So, for few ms we have 2 error components are visible in the screen. I want that if one is staying on the top of the screen no other component should be mounted.