-
Notifications
You must be signed in to change notification settings - Fork 9k
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 18 support #8414
React 18 support #8414
Conversation
562ee5c
to
87605cc
Compare
Hi @sybernatus, Thanks for the work on this. I was wondering is you see any warnings or errors in console. This is candidate for inclusion into v5 release, from the |
Hi @char0n, I ran the app on my local and no errors/warnings showed up in the console. Do I need to perform another action? 🚀 |
@sybernatus I'm currently in the process of consolidation |
@sybernatus would you mind sending this PR against the |
87605cc
to
bfb6db9
Compare
Done. Tell me if you need another action on my side 🙂 |
@sybernatus thanks! Let me explain what are the next steps and expectations: We have to introduce, React@18 in completely backward compatible way. This means that we'll have to support following range in "react": ">=17.0.2 <19",
"react-dom": ">=17.0.2 < 19", If upstream consumer will need to pin the react version, it would be possible in npm with Next thing is Of course our tests will assume react@18 is always installed (to eliminate complexity). |
Do you mean something like that ? |
Yes something like that, but more scalable. I'd modify the export const render = (getSystem, getStore, getComponent, getComponents) => (domNode) => {
const App = getComponent(getSystem, getStore, getComponents)("App", "root")
const { createRoot } = require('react-dom/client')
const root = createRoot(domNode)
root.render(<App/>)
} Reasoning: this is forward compatible way of mounting react now. It will probably not change for some time now. We use Next I'd introduce src/core/plugins/react-17/root-injects.js export const render = (getSystem, getStore, getComponent, getComponents) => (domNode) => {
const App = getComponent(getSystem, getStore, getComponents)("App", "root")
const ReactDOM = require("react-dom")
ReactDOM.render(<App/>, domNode)
} src/core/plugins/react-17/index.js; import { render } from "./root-injects"
const React17Plugin = ({ getSystem }) => {
const { React } = getSystem()
const rootInjects = {}
if (React.version?.match(/^17/)) {
rootInjects.render = render;
}
return {
rootInjects,
}
} Now this would basically override the |
Thanks, it's done 🙂 |
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.
I'm checking sorry, tests are not passing. |
I have one test that I can figure out why it's not passing.
I didn't change any inputs, I think so I don't understand why the received message changed to |
Hi @sybernatus,
The jest tests are depending on Now in this case, it looks like from what ever reason the older version of |
Hi again @sybernatus, I had a hour to spare today and followed up on your work in #8888. I've incorporated your changes + some additional changes that were required for backward compatibility with React@17 and React@16. Now the question is how we're going to do the merge so that we don't loose your attribution. I'm suggesting you merge char0n/react-18-support into your |
Hm, I can actually see regressions in SwaggerUI behavior on React@18. One of these regressions can be seen here: https://github.com/swagger-api/swagger-ui/actions/runs/5190826908/jobs/9357817486?pr=8888. This needs to be investigated before we can go further. |
You're right I have also this cypress issues in local. I'm checking. |
I did spent couple of minutes on this regression, but couldn't find a root cause. We'll have to inspect the components involved and find out why this happens. I'll try to find time during this week to look at it in more details. |
Indeed, I spent several hours yesterday tackling this issue. Since I'm new to this repository, I'm still figuring out where the loading process for the URL test page is located. Regardless, this is a definite regression, as I was able to reproduce the issue locally. I'll find some more time this week on this. |
@sybernatus I've update the Cypress to latest version so that we have the latest testing tools. Please rebase your branch on top of |
… server variables
This support is fully backward complatible with React@17. Refs swagger-api#8126
…cluded server variables
a455246
to
132f704
Compare
It seems that going from React 17 to 18, the re-rendering of server.jsx is not well executed. the function If you have any idea how to solve this, I take it. 😵💫 Still trying to figure it out EDIT It seems that the function UNSAFE_componentWillReceiveProps() in server.jsx is triggered multiple times in react 17 but only once in React 18. In react 17
Still investigating why.. |
@sybernatus any luck so far? And thank you for pinpointing the actual place of issue. I assume that |
Some more additional info https://www.geeksforgeeks.org/reactjs-unsafe_componentwillreceiveprops-method/ |
This PR has been superseded by #9435. |
Update to support react 18.
Related issue : #8126
Description
@wojtekmaj/enzyme-adapter-react-17
library to@cfaester/enzyme-adapter-react-18
ReactDOM
usage (deprecated in react 18) bycreateRoot
Motivation and Context
The change is required to integrate swagger-ui to react 18 application
How Has This Been Tested?
npm run test
&npm run test-in-node
)Screenshots (if appropriate):
Checklist
My PR contains...
src/
is unmodified: changes to documentation, CI, metadata, etc.)package.json
)My changes...
Documentation
Automated tests