toss / overlay-kit

The simplest and most intuitive way to manage overlays in React.
https://overlay-kit.slash.page
MIT License
295 stars 30 forks source link

feat: Add cleanup effect for unmounting #64

Closed jungpaeng closed 4 months ago

jungpaeng commented 4 months ago

This commit adds a useEffect cleanup function to the OverlayProvider component that dispatches a ‘REMOVE_ALL’ action upon unmounting. This ensures that overlays are properly cleaned up during testing scenarios, preventing state leakage and side effects from persistent overlays.

Description

This commit introduces a useEffect cleanup function in the OverlayProvider component that dispatches a 'REMOVE_ALL' action when the component unmounts. This change ensures that all overlays are properly cleaned up during testing scenarios, preventing state leakage and side effects from persistent overlays.

Related Issue: Fixes #63

Changes

Motivation and Context

This change is necessary to enhance the testability of the OverlayProvider by ensuring overlays do not persist state across tests, which can lead to unpredictable behavior and flaky tests.

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

Checklist

Further Comments

vercel[bot] commented 4 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
overlay-kit ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 17, 2024 4:39pm
changeset-bot[bot] commented 4 months ago

🦋 Changeset detected

Latest commit: 6ba184eeec88a58056c2cba8af1f64ec344dfcbe

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages | Name | Type | | -------------------------- | ----- | | overlay-kit | Patch | | @overlay-kit/framer-motion | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR