diff --git a/src/index.js b/src/index.js index decd8fa9..1091c979 100644 --- a/src/index.js +++ b/src/index.js @@ -3,7 +3,7 @@ import './webpack-public-path'; import App from './app'; import domReady from '@wordpress/dom-ready'; -import { createRoot } from '@wordpress/element'; +import {createRoot, render} from '@wordpress/element'; const WP_ADM_PAGE_ROOT_ELEMENT = 'hwa-app'; const HG_ASCI = ` @@ -45,10 +45,14 @@ console.log(HG_ASCI); const HGWPRender = () => { const DOM_ELEMENT = document.getElementById( WP_ADM_PAGE_ROOT_ELEMENT ); - if ( null !== DOM_ELEMENT && 'undefined' !== typeof createRoot ) { - const root = createRoot( DOM_ELEMENT ); - root.render( ); - } + if (null !== DOM_ELEMENT) { + if ('undefined' !== typeof createRoot) { + // WP 6.2+ only + createRoot(DOM_ELEMENT).render(); + } else if ('undefined' !== typeof render) { + render(, DOM_ELEMENT); + } + } }; domReady( HGWPRender ); \ No newline at end of file