Skip to content

Instantly share code, notes, and snippets.

@p-jackson
Created February 4, 2020 08:55
Show Gist options
  • Save p-jackson/fe601434d0ab5202387f9799ebae184e to your computer and use it in GitHub Desktop.
Save p-jackson/fe601434d0ab5202387f9799ebae184e to your computer and use it in GitHub Desktop.
Testing block with notice in placeholder
/**
* WordPress dependencies
*/
import { Placeholder, withNotices } from '@wordpress/components';
import { useEffect } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { resizeCornerNE as icon } from '@wordpress/icons';
const Edit = withNotices( ( { noticeOperations, noticeUI } ) => {
useEffect( () => {
noticeOperations.createErrorNotice( "I'm surrounded by errors!" );
}, [] );
return (
<Placeholder notices={ noticeUI }>
<p>nothing to see here</p>
</Placeholder>
);
} );
export const name = 'core/testing';
export const metadata = { category: 'layout' };
export const settings = {
title: __( 'Testing' ),
description: __( 'just does testing' ),
icon,
edit() {
return <Edit />;
},
save() {
return <p />;
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment