Skip to content

Commit

Permalink
Re-enable React StrictMode (#61943)
Browse files Browse the repository at this point in the history
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: youknowriad <[email protected]>
Co-authored-by: tyxla <[email protected]>
Co-authored-by: kevin940726 <[email protected]>
Co-authored-by: ellatrix <[email protected]>
  • Loading branch information
6 people authored Jun 4, 2024
1 parent e57eed5 commit 736121f
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 19 deletions.
14 changes: 8 additions & 6 deletions packages/customize-widgets/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { createRoot } from '@wordpress/element';
import { createRoot, StrictMode } from '@wordpress/element';
import {
registerCoreBlocks,
__experimentalGetCoreBlocks,
Expand Down Expand Up @@ -92,11 +92,13 @@ export function initialize( editorName, blockEditorSettings ) {
} );

createRoot( container ).render(
<CustomizeWidgets
api={ wp.customize }
sidebarControls={ sidebarControls }
blockEditorSettings={ blockEditorSettings }
/>
<StrictMode>
<CustomizeWidgets
api={ wp.customize }
sidebarControls={ sidebarControls }
blockEditorSettings={ blockEditorSettings }
/>
</StrictMode>
);
} );
}
Expand Down
16 changes: 9 additions & 7 deletions packages/edit-post/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
__experimentalRegisterExperimentalCoreBlocks,
} from '@wordpress/block-library';
import deprecated from '@wordpress/deprecated';
import { createRoot } from '@wordpress/element';
import { createRoot, StrictMode } from '@wordpress/element';
import { dispatch, select } from '@wordpress/data';
import { store as preferencesStore } from '@wordpress/preferences';
import {
Expand Down Expand Up @@ -137,12 +137,14 @@ export function initializeEditor(
window.addEventListener( 'drop', ( e ) => e.preventDefault(), false );

root.render(
<Editor
settings={ settings }
postId={ postId }
postType={ postType }
initialEdits={ initialEdits }
/>
<StrictMode>
<Editor
settings={ settings }
postId={ postId }
postType={ postType }
initialEdits={ initialEdits }
/>
</StrictMode>
);

return root;
Expand Down
8 changes: 6 additions & 2 deletions packages/edit-site/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '@wordpress/block-library';
import { dispatch } from '@wordpress/data';
import deprecated from '@wordpress/deprecated';
import { createRoot } from '@wordpress/element';
import { createRoot, StrictMode } from '@wordpress/element';
import { store as editorStore } from '@wordpress/editor';
import { store as preferencesStore } from '@wordpress/preferences';
import {
Expand Down Expand Up @@ -85,7 +85,11 @@ export function initializeEditor( id, settings ) {
window.addEventListener( 'dragover', ( e ) => e.preventDefault(), false );
window.addEventListener( 'drop', ( e ) => e.preventDefault(), false );

root.render( <App /> );
root.render(
<StrictMode>
<App />
</StrictMode>
);

return root;
}
Expand Down
8 changes: 6 additions & 2 deletions packages/edit-widgets/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '@wordpress/blocks';
import { dispatch } from '@wordpress/data';
import deprecated from '@wordpress/deprecated';
import { createRoot } from '@wordpress/element';
import { StrictMode, createRoot } from '@wordpress/element';
import {
registerCoreBlocks,
__experimentalGetCoreBlocks,
Expand Down Expand Up @@ -91,7 +91,11 @@ export function initializeEditor( id, settings ) {
// see: https://github.com/WordPress/gutenberg/issues/33097
setFreeformContentHandlerName( 'core/html' );

root.render( <Layout blockEditorSettings={ settings } /> );
root.render(
<StrictMode>
<Layout blockEditorSettings={ settings } />
</StrictMode>
);

return root;
}
Expand Down
6 changes: 4 additions & 2 deletions packages/list-reusable-blocks/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { createRoot } from '@wordpress/element';
import { createRoot, StrictMode } from '@wordpress/element';
import { __ } from '@wordpress/i18n';

/**
Expand Down Expand Up @@ -44,6 +44,8 @@ document.addEventListener( 'DOMContentLoaded', () => {
container.className = 'list-reusable-blocks__container';
button.parentNode.insertBefore( container, button );
createRoot( container ).render(
<ImportDropdown onUpload={ showNotice } />
<StrictMode>
<ImportDropdown onUpload={ showNotice } />
</StrictMode>
);
} );

0 comments on commit 736121f

Please sign in to comment.