refactor: remove derived state useEffects from Carousel and Disclosure#183
Open
vass-k wants to merge 1 commit intoibelick:mainfrom
Open
refactor: remove derived state useEffects from Carousel and Disclosure#183vass-k wants to merge 1 commit intoibelick:mainfrom
vass-k wants to merge 1 commit intoibelick:mainfrom
Conversation
- Removed redundant `useEffect` hooks used for state syncing - Refactored [Carousel] to pass the correct active index down to the provider, eliminating duplicated state. - Refactored [Disclosure] to properly handle controlled and uncontrolled modes using an `isControlled` check during render. - Zero changes to the public API; all existing consumption works exactly the same.
Contributor
|
@vass-k is attempting to deploy a commit to the julienthibeaut's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
What changed?
This PR refactors the internal state management for the
<Carousel>and<Disclosure>components to fix theDerived state in useEffectwarnings flagged by React Doctor.Both components previously relied on a
useEffectto sync external prop changes into duplicated local state, which is an anti-pattern that causes unnecessary double-rendering.How it improves the components
useEffectsyncs removes the sluggish double-render cycle entirely. When a controlled value changes, the component now updates the UI in a single pass.isControlled).compute during render instead) are fully resolved.User Impact
None. The public API for both components is completely unchanged. No documentation updates are required, and existing usages of
<Carousel>and<Disclosure>will automatically benefit from the cleaner rendering cycle.