Skip to content

Commit

Permalink
Merge pull request #418 from t-hamano/quality/compatible-react-render
Browse files Browse the repository at this point in the history
Fix: react render warning
  • Loading branch information
mikachan authored Jul 14, 2023
2 parents 1233e3d + 23ea4fb commit 9aec9f5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from '@wordpress/element';
import { render, createRoot } from '@wordpress/element';
import ManageFonts from './manage-fonts';
import GoogleFonts from './google-fonts';
import LocalFonts from './local-fonts';
Expand Down Expand Up @@ -34,7 +34,16 @@ function App() {
window.addEventListener(
'load',
function () {
render( <App />, document.querySelector( '#create-block-theme-app' ) );
const domNode = document.getElementById( 'create-block-theme-app' );

// If version is less than 18 use `render` to render the app
// otherwise use `createRoot` to render the app
if ( createRoot === undefined ) {
render( <App />, domNode );
} else {
const root = createRoot( domNode );
root.render( <App /> );
}
},
false
);

0 comments on commit 9aec9f5

Please sign in to comment.