Last active
March 19, 2025 02:21
-
-
Save VelichkoAlexander/24f561e1506586d2204e4448f181d346 to your computer and use it in GitHub Desktop.
How to work with preview state for Gutenberg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {useSelect, useDispatch} from '@wordpress/data' | |
//Access the current mode value | |
const { deviceType } = useSelect( select => { | |
const { __experimentalGetPreviewDeviceType } = select( 'core/edit-post' ); | |
return { | |
deviceType: __experimentalGetPreviewDeviceType(), | |
} | |
}, [] ); | |
//Resize the site editor programmatical | |
wp.data.dispatch('core/edit-post').__experimentalSetPreviewDeviceType('Tablet'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment