clauderic / dnd-kit

The modern, lightweight, performant, accessible and extensible drag & drop toolkit for React.
http://dndkit.com
MIT License
11.9k stars 602 forks source link

replace useReducer with useState #1435

Open knaveenkumar3576 opened 2 weeks ago

knaveenkumar3576 commented 2 weeks ago

This PR includes three changes:

useDroppable function: Changed useIsomorphicLayoutEffect to useEffect Although setting state in a layout effect is useful for measuring the DOM, in this case, it only registers droppable elements during the first render. It can wait until later without causing any UI flickers.

useRect function: Replaced useReducer with useState. Switched to useState because useReducer causes nested updates due to the lack of a bailout mechanism.

useRects function: Replaced useReducer with useState. Switched to useState because useReducer causes nested updates due to the lack of a bailout mechanism .

Please review @clauderic

changeset-bot[bot] commented 2 weeks ago

⚠️ No Changeset found

Latest commit: 5a724502c3072919a07ef1c41b6ae537404098b4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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