'React Router 6 unmount component on route change

I use the same component on different react router routes. Does anyone know how to unmount component on route change? Now when I change the route, component doesn't unmount, here is my example: https://codesandbox.io/s/stupefied-cloud-bxfyf?file=/src/MyComponent.js



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source