-
Notifications
You must be signed in to change notification settings - Fork 658
React - useImperativeHandle dependencies fix and useCallbacks' cleanup (T1308983) #31869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React - useImperativeHandle dependencies fix and useCallbacks' cleanup (T1308983) #31869
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes critical React hooks usage issues in the DevExtreme React wrapper core components by correcting useCallback and useImperativeHandle dependency arrays. The changes prevent unnecessary re-renders and stale closure bugs by implementing the proper pattern of using refs to track the latest function versions while keeping imperative handles stable.
- Removes incorrect mutable ref values from
useCallbackanduseImperativeHandledependency arrays - Implements the ref-tracking pattern to ensure imperative handles always call the latest function versions without recreating
- Adds test coverage to verify component refs remain accessible during controlled state updates
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/devextreme-react/src/core/extension-component.tsx | Fixed useCallback and useImperativeHandle dependencies; added ref-tracking pattern for createWidget |
| packages/devextreme-react/src/core/component.tsx | Fixed useCallback and useImperativeHandle dependencies; added ref-tracking pattern for createWidget and clearExtensions; modernized optional chaining syntax |
| packages/devextreme-react/src/core/component-base.tsx | Fixed multiple useCallback and useImperativeHandle dependencies; added ref-tracking patterns for createWidget and restoreParentLink |
| packages/devextreme-react/src/core/tests/test-component.tsx | Updated test component to follow the same ref-tracking pattern; added missing semicolon |
| packages/devextreme-react/src/core/tests/props-updating.test.tsx | Added test case to verify component refs remain defined during controlled selection updates; imported fireEvent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
No description provided.