argument of type 'htmlelement | null' is not assignable to parameter of type 'element'. type 'null' is not assignable to type 'element'. ts(2345)
import.js
import React from 'react';
import { createRoot } from 'react-dom/client';
import './index.css';
import App from './App';
const container = document.getElementById('root')
const root = createRoot(container)
root.render(<App />)
Top comments (1)
It's probably thinking that
document.getElementById
can be either an htmlelement or null (if it can't find that identifier in the DOM) so it fails in createRoot trying to ensure what you send to it is effectively anelement
.