May be a stupid question.
import {ReactDOM} from 'react-dom/client'; // or import {ReactDOM as ReactDOM} are BAD
...
const root = ReactDOM.createRoot(document.getElementById("root"));
received error:
export 'ReactDOM' (imported as 'ReactDOM') was not found in 'react-dom/client' (possible exports: createRoot, hydrateRoot)
OK only import ReactDOM from 'react-dom/client';
This is different from this post
CodePudding user response:
Apologies if I'm misunderstanding the question, but assuming I'm on point, the difference is how they are exported from the package.
ReactDOM is export default
whereas the others (createRoot
, hydrateRoot
) are export
only.
For more info: `export const` vs. `export default` in ES6
(and based on the fact that post has over 290 upvotes - not a silly question at all)