I have following error when use react-dom/client
Compiled with problems:X
ERROR in src/index.tsx:2:28
TS7016: Could not find a declaration file for module 'react-dom/client'. 'C:/Users/Mohamad/Desktop/HIS/Administration/Administration/Administration/Administration.Endpoints.WebUI/ClientApp/node_modules/react-dom/client.js' implicitly has an 'any' type.
Try `npm install @types/react-dom` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-dom/client';`
1 | import * as React from 'react';
> 2 | import { createRoot } from 'react-dom/client';
| ^^^^^^^^^^^^^^^^^^
3 | import App from './App';
4 |
5 |
Install @types/react-dom with @latest
npm i @types/react-dom@latest
Error message actually states the solution:
You need to install the package or define in .d.ts
file
However for my case, I had to do both of them to resolve the issue.
Install the package:
npm install @types/react-dom
Define in .d.ts
declare module 'react-dom/client';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With