Skip to content

Conversation

@hansolc
Copy link

@hansolc hansolc commented Dec 5, 2025

Description

This PR refactors the useEffectEvent hook implementation and updates useControllableState to use the new useEffectEvent hook for stable callback references.

Changes

packages/react/use-effect-event/src/use-effect-event.tsx

  • remove boilerplate codes relate with useReactInsertionEffect

packages/react/use-controllable-state/src/use-controllable-state.tsx

  • Replaced manual useRef + useEffect pattern with useEffectEvent hook
  • Simplified the useUncontrolledState implementation by using useEffectEvent for stable onChange callbacks
  • Remove useInsertionEffect hook

Benefits

  • Cleaner code: Removes boilerplate ref management code
  • Future-proof: Ready to seamlessly adopt React's native useEffectEvent when it becomes stable

Testing

  • All existing tests pass
  • NO UI component changes, Storybook examples unaffected

…ableState` and `useUncontrolledState` for improved stability. Remove unused `useInsertionEffect` import from `useEffectEvent`.
@changeset-bot
Copy link

changeset-bot bot commented Dec 5, 2025

🦋 Changeset detected

Latest commit: 6559cdf

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

This PR includes changesets to release 28 packages
Name Type
@radix-ui/react-use-controllable-state Patch
@radix-ui/react-use-effect-event Patch
@radix-ui/react-accordion Patch
@radix-ui/react-checkbox Patch
@radix-ui/react-collapsible Patch
@radix-ui/react-context-menu Patch
@radix-ui/react-dialog Patch
@radix-ui/react-dropdown-menu Patch
@radix-ui/react-hover-card Patch
@radix-ui/react-menubar Patch
@radix-ui/react-navigation-menu Patch
@radix-ui/react-one-time-password-field Patch
@radix-ui/react-password-toggle-field Patch
@radix-ui/react-popover Patch
@radix-ui/react-radio-group Patch
radix-ui Patch
@radix-ui/react-roving-focus Patch
@radix-ui/react-select Patch
@radix-ui/react-slider Patch
@radix-ui/react-switch Patch
@radix-ui/react-tabs Patch
@radix-ui/react-toast Patch
@radix-ui/react-toggle-group Patch
@radix-ui/react-toggle Patch
@radix-ui/react-tooltip Patch
@radix-ui/react-alert-dialog Patch
@radix-ui/react-menu Patch
@radix-ui/react-toolbar 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant