Warning

April 13, 2021 ยท View on GitHub

Displays a warning message, typically in the context of a particular block. It may present given actions to the user.

As seen in BlockInvalidWarning:

warning-block-invalid

As seen in withMultipleValidation:

warning-block-use-once

Usage

Props

All of the following are optional.

  • children: Intended to represent the block to which the warning pertains. See screenshots above.

  • className: Classes to pass to element.

  • actions: An array of elements to be rendered as action buttons in the warning element.

  • secondaryActions: An array of { title, onClick } to be rendered as options in a dropdown of secondary actions.

Example

<Warning
	actions={ [ <Button onClick={ fixIssue }>{ __( 'Fix issue' ) }</Button> ] }
	secondaryActions={ [
		{
			title: __( 'Get help' ),
			onClick: getHelp,
		},
		{
			title: __( 'Remove block' ),
			onClick: removeBlock,
		},
	] }
>
	{ __( 'This block ran into an issue.' ) }
</Warning>