使用法
import { withNotices, Button } from '@wordpress/components';
const MyComponentWithNotices = withNotices(
( { noticeOperations, noticeUI } ) => {
const addError = () =>
noticeOperations.createErrorNotice( 'Error message' );
return (
<div>
{ noticeUI }
<Button variant="secondary" onClick={ addError }>
Add error
</Button>
</div>
);
}
);