| 1 |
const {render} = wp.element; //we are using wp.element here! |
| 2 |
const {createRoot} = wp.element; //we are using wp.element here! |
| 3 |
import App from './App'; |
| 4 |
|
| 5 |
const domElement = document.getElementById('react-root'); |
| 6 |
const uiElement = <App/>; |
| 7 |
|
| 8 |
//check if element exists before rendering |
| 9 |
if (domElement) { |
| 10 |
|
| 11 |
/** |
| 12 |
* Use the proper render method depending on the React version (which depends |
| 13 |
* on the WP version) |
| 14 |
*/ |
| 15 |
if ( createRoot ) { |
| 16 |
createRoot( domElement ).render( uiElement ); |
| 17 |
} else { |
| 18 |
render( uiElement, domElement ); |
| 19 |
} |
| 20 |
|
| 21 |
} |
| 22 |
|