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
Problem referencing 'react-dom/client' in React 18 #2389
Comments
I think that, in this case, you need a new entry in the import map. {
"imports": {
"react": "/lib/react/umd/react.development.js",
"react-dom": "/lib/react-dom/umd/react-dom.development.js",
"react-dom/client": "/lib/react-dom/path-for-client-file.js"
}
} |
@arthurdenner, the "react-dom/client" logic appears to be hosted in the "react-dom.development.js" file and not in a separate file. When I point "react-dom" at that JS file I end up with the |
It turns out the issue was with React 18. React 18.0.0 was generating the error described above. I just updated to React 18.1.0 and the error went away. My last version of the code, which generated the warning about the import source above, was the correct one. That means that having the import map read the following is the only SystemJS change that was necessary: {
"imports": {
"react": "/lib/react/umd/react.development.js",
"react-dom/client": "/lib/react-dom/umd/react-dom.development.js"
}
} After that, the TypeScript code I listed above worked fine. Just to confirm, I switched back to React 18.0.0. The error returned. Moving to 18.1.0 once again got rid of the error with no other changes needed. And with a little further research, the issue is a listed fix in the 18.1.0 release notes:
|
@StuffOfInterest, I'm glad you could figure out the issue. |
Question
Trying to convert from React 17 to React 18 in an MVC based website that uses TypeScript for much of the code. Had React 17 working with an import map that contained the following:
To get my component on the page I was using
ReactDOM.render()
before with this import:New method of rendering the component requires a different types of import:
Unfortunately, when I try this pattern, and then use the
createRoot()
function, I get the following error:I've tried a few things but can't come up with a way to make "react-dom/client" map back into the react-dom module. The closest I've gotten is if I change the map for "react-dom" to "react-dom/client" the component does render, but I see another error in the console:
The TypeScript code being used to start up the component reads:
The text was updated successfully, but these errors were encountered: