-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: race conditions in usePersistedDevicePreferences (#1575)
When mounting and unmounting `usePersistedDevicePreferences` hook in quick succession, the following race conditions can occur: 1. `useApplyDevicePreferences` can apply style preferences, since the effect it runs is async and is not canceled on unmount. 2. `usePersistDevicePreferences` can write new device preferences (most likely, the default ones) before they were applied. This is fixed by adding cancelation to the effect in `useApplyDevicePreferences`, and by preventing `usePersistDevicePreferences` from running before `useApplyDevicePreferences` completes.
- Loading branch information
1 parent
142d839
commit 08aacc4
Showing
1 changed file
with
29 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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