Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use createReact and render method when possible #59

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/Installer/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import './styles/app.scss';
* WordPress dependencies
*/
import domReady from '@wordpress/dom-ready';
import { render } from '@wordpress/element';
import { createRoot, render } from '@wordpress/element';

/**
* Internal dependencies
Expand All @@ -34,6 +34,12 @@ const renderModal = ( elementId ) => {
if ( ! document.getElementById( elementId ) ) {
document.body.append( modalRoot );
}

render( <App />, modalRoot );
// react render depending on wp version
if ( 'undefined' !== typeof createRoot ) {
// wp 6.2 and above
createRoot( modalRoot ).render( <App /> );
} else if ( 'undefined' !== typeof render ) {
// wp 6.1 and below
render( <App />, modalRoot );
}
};
Loading