-
Notifications
You must be signed in to change notification settings - Fork 9.1k
aBug/10212 refactor unsafe components #10373
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
base: master
Are you sure you want to change the base?
aBug/10212 refactor unsafe components #10373
Conversation
UNSAFE_componentWillReceiveProps is a deprecated lifecycle method in React 16.3+ and has been removed in Strict Mode and React 18+
Fix reactDOM inmport error: Warning: You are importing createRoot from "react-dom" which is not supported. You should instead import it from "react-dom/client".
Someone merge this please |
@jryanthe4th thank you for your contribution and the time spent on refactoring 🙏 A few changes are unrelated to the refactoring of unsafe components. We would appreciate it if you could create separate PRs for these, as it would make it easier to track the changes in the commit history Addressing the ReactDOM warning would lead to the loss of support for React 16 and 17, given that the client API was introduced in React 18 |
Addressing the ReactDOM warning would lead to the loss of support for React 16 and 17, given that the client API was introduced in React 18
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 refactors legacy lifecycle methods to modern React patterns and fixes a React 18-related import issue.
- Refactors OperationContainer to use componentDidUpdate instead of UNSAFE_componentWillReceiveProps with enhanced checks for state updates.
- Rewrites ContentType to update its state in componentDidUpdate and improves code clarity and efficiency.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/core/containers/OperationContainer.jsx | Replaced UNSAFE_componentWillReceiveProps with componentDidUpdate and refined request triggering logic. |
src/core/components/content-type.jsx | Replaced unsafe lifecycle method with componentDidUpdate and refined initial value handling. |
Comments suppressed due to low confidence (1)
src/core/containers/OperationContainer.jsx:101
- [nitpick] Ensure that isShown is always a boolean; if there's a possibility that it could be a non-boolean truthy value, consider explicitly comparing with 'true' to avoid any unexpected behavior.
if (isShown && resolvedSubtree === undefined && !prevProps.isShown) {
Description
OperationContainer
changes:ContentType
changes:root-injects.jsx
changes:Fix reactDOM import error:
Warning: You are importing createRoot from "react-dom" which is not supported. You should instead import it from "react-dom/client".
Motivation and Context
Swagger-ui throws errors when used with react 18 due to the deprecation of UNSAFE_componentWillReceiveProps.
#10212
Fixes #10212
How Has This Been Tested?
Ran the app locally and clicked multiple links and buttons
Screenshots (if appropriate):
Checklist
My PR contains...
src/
is unmodified: changes to documentation, CI, metadata, etc.)package.json
)My changes...
Documentation
Automated tests