File tree Expand file tree Collapse file tree 4 files changed +16
-4
lines changed
Expand file tree Collapse file tree 4 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 77 </ head >
88
99 < body >
10- < div id ="react- root "> </ div >
10+ < div id ="root "> </ div >
1111 < script type ="module " src ="./index.tsx "> </ script >
1212 </ body >
1313</ html >
Original file line number Diff line number Diff line change @@ -2,4 +2,10 @@ import { createRoot } from 'react-dom/client';
22
33import Sample from './Sample.js' ;
44
5- createRoot ( document . getElementById ( 'react-root' ) ! ) . render ( < Sample /> ) ;
5+ const root = document . getElementById ( 'root' ) ;
6+
7+ if ( ! root ) {
8+ throw new Error ( 'Could not find root element' ) ;
9+ }
10+
11+ createRoot ( root ) . render ( < Sample /> ) ;
Original file line number Diff line number Diff line change 77 </ head >
88
99 < body >
10- < div id ="react- root "> </ div >
10+ < div id ="root "> </ div >
1111 < script type ="module " src ="./index.tsx "> </ script >
1212 </ body >
1313</ html >
Original file line number Diff line number Diff line change @@ -3,7 +3,13 @@ import { createRoot } from 'react-dom/client';
33
44import Test from './Test.js' ;
55
6- createRoot ( document . getElementById ( 'react-root' ) ! ) . render (
6+ const root = document . getElementById ( 'root' ) ;
7+
8+ if ( ! root ) {
9+ throw new Error ( 'Could not find root element' ) ;
10+ }
11+
12+ createRoot ( root ) . render (
713 < StrictMode >
814 < Test />
915 </ StrictMode > ,
You can’t perform that action at this time.
0 commit comments