Repository navigation
Re-arm useDebouncedMemo's mounted ref on mount - #1208
Open
theluckystrike wants to merge 1 commit into
Open
theluckystrike wants to merge 1 commit into
theluckystrike wants to merge 1 commit into
Conversation
Under React.StrictMode the mount effect runs, its cleanup runs, then the effect runs again. useDebouncedMemo set mountedRef to false in the cleanup and never set it back, so the debounced value never updated and the accessibility tree rendered zero cells (glideapps#1198). The effect now sets mountedRef to true when it runs, which is the four-line change suggested in the issue. Unmount still stops a pending update. Tests in test/use-debounced-memo.test.tsx render the hook with and without StrictMode and check that it updates after the debounce, and that an unmounted hook does not update. The StrictMode test fails without this change. The core vitest suite (390 tests), eslint and prettier pass; tsc reports the same 20 errors as main, none in these files. Fixes glideapps#1198
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1198.
Under React.StrictMode the mount effect runs, its cleanup runs, and then the effect runs again. useDebouncedMemo set mountedRef to false in the cleanup and never set it back, so the debounced value never updated and the accessibility tree rendered zero cells.
The effect now sets mountedRef to true when it runs, which is the four-line change suggested in the issue. Unmount still stops a pending update.
New tests in test/use-debounced-memo.test.tsx render the hook with and without StrictMode, check that it updates after the debounce, and check that an unmounted hook does not update. The StrictMode test fails on main. The core vitest suite (390 tests), eslint and prettier pass. tsc reports the same errors as main, none in these files.