Open minsgy opened 1 month ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
react-hot-toast | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | May 30, 2024 3:11pm |
@minsgy is attempting to deploy a commit to the analytics-billing-vtest314 Team on Vercel.
A member of the Team first needs to authorize it.
as-is
The original code used
useEffect
to register thevisibilitychange
event on the document and update the state based on the document's visibility state in the event handler.to-be
The updated code uses
useSyncExternalStore
to synchronize the external state changes.useSyncExternalStore
provides asubscribe
function to detect changes in the external state and a function to retrieve the current state. This allows for efficient observation of the document's visibility state changes and updating the state accordingly. These changes have improved the readability and efficiency of the code.