# tablepress/3.3.3/admin/js/common/react-loader.js

TablePress – Tables in WordPress made easy, version 3.3.3. 69 lines.

- Page: https://pluginprobe.com/plugins/tablepress/3.3.3/code/admin/js/common/react-loader.js
- Raw: https://pluginprobe.com/plugins/tablepress/3.3.3/raw/admin/js/common/react-loader.js
- Modified: 2026-05-20T03:43:36+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/tablepress/3.3.3/code/admin/js/common/react-loader.js#L10-L20`.

```javascript
/**
 * Common functions for loading React components in TablePress JS.
 *
 * @package TablePress
 * @subpackage Views JavaScript
 * @author Tobias Bäthge
 * @since 2.2.0
 */

/**
 * WordPress dependencies.
 */
import { StrictMode } from 'react';
import { createPortal, createRoot } from 'react-dom';
import domReady from '@wordpress/dom-ready';
import { addFilter } from '@wordpress/hooks';

/**
 * Initializes a React component on the page.
 *
 * @param {string}    rootId    HTML ID of the root element for the component.
 * @param {Component} Component JSX component.
 */
export const initializeReactComponent = ( rootId, Component ) => {
	domReady( () => {
		if ( process.env.DEVELOP ) {
			Component = <StrictMode>{ Component }</StrictMode>;
		}

		const root = document.getElementById( rootId );
		if ( root ) {
			createRoot( root ).render( Component );
		}
	} );
};

/**
 * Initializes a React component on the page, in a React Portal, and registers its meta box.
 *
 * @param {string}    slug      Slug of the component/feature module.
 * @param {string}    screen    Slug/action of the screen.
 * @param {Component} Component JSX component.
 */
export const initializeReactComponentInPortal = ( slug, screen, Component ) => {
	addFilter(
		`tablepress.${screen}ScreenFeatures`,
		`tp/${slug}/${screen}-screen-feature`,
		( features ) => ( [ ...features, slug ] ),
	);

	addFilter(
		`tablepress.${screen}ScreenPortals`,
		`tp/${slug}/${screen}-screen-portal`,
		( Portals ) => {
			return ( props ) => (
				<>
					<Portals { ...props } />
					{
						createPortal(
							<Component { ...props } />,
							document.getElementById( `tablepress-${slug}-section` ),
						)
					}
				</>
			);
		},
	);
};

```
