Closed
Description
I'm using the Offcanvas component like the following :
....
<Offcanvas
style={{ '--bs-offcanvas-height': '60vh' }}
scroll={false}
placement='bottom'
show={isDrawerOpen()}
onHide={() => setIsDrawerOpen(false)}
>
<Offcanvas.Body class={styles.myOffcanvasBodyStyles}>
<MyComponent />
</Offcanvas.Body>
</Offcanvas>
I am using onMount
and onCleanup
lifecycle hooks inside MyComponent
.
If I open and dismiss the offcanvas drawer repeatedly, I notice the onMount hook firing on every open. But the onCleanup hook doesn't fire on every dismiss. It only fires when I route away from the entire page.
And it fires multiple instances of onCleanup (equal to the number of times I opened the modal), which means each instance of opening the Offcanvas is mounting a new component and it stays around, never getting cleaned up until we leave the page.
This is a memory leak and leads to a laggy UI after a while of normal usage (which involves many opening/closings of the Offcanvas).
Metadata
Metadata
Assignees
Labels
No labels