You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Open console and see that the cleanup function for the button component is never invoked
Current behavior
A MUI component that is passed a ref callback function which returns a cleanup function does not have its cleanup function invoked when the component is unmounted. It instead passes null to callback function.
Expected behavior
Material components with ref callback functions that return a cleanup function should properly execute the cleanup function when the component is unmounted.
I have a list of search results, where each result item includes a checkbox. I have a context that tracks state of number selected, the selected values, and an array of all of the checkboxes that are mounted. The state is maintained with a reducer.
I want to use the ref cleanup function to remove this element from the tracked state data.
Steps to reproduce
Steps:
Current behavior
A MUI component that is passed a ref callback function which returns a cleanup function does not have its cleanup function invoked when the component is unmounted. It instead passes null to callback function.
Expected behavior
Material components with ref callback functions that return a cleanup function should properly execute the cleanup function when the component is unmounted.
See https://react.dev/reference/react-dom/components/common#ref-callback.
Context
I have a list of search results, where each result item includes a checkbox. I have a context that tracks state of number selected, the selected values, and an array of all of the checkboxes that are mounted. The state is maintained with a reducer.
I want to use the ref cleanup function to remove this element from the tracked state data.
Your environment
npx @mui/envinfo
Search keywords: ref callback cleanup react 19
The text was updated successfully, but these errors were encountered: