Skip to content

Commit

Permalink
PreviewOptions: Fix critical error when children not passed (#54284)
Browse files Browse the repository at this point in the history
* Preview Options: Fix critical error when children not passed

* Use optional chaining
  • Loading branch information
t-hamano authored Sep 12, 2023
1 parent 94aad94 commit c04e420
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ Used to set the device type that will be used to display the preview inside the
- Type: `func`
- Required: yes

#### children

A function that returns nodes to be rendered within the dropdown.

- Type: `Function`
- Required: No

## Related components

Block Editor components are components that can be used to compose the UI of your block editor. Thus, they can only be used under a [`BlockEditorProvider`](https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/provider/README.md) in the components tree.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default function PreviewOptions( {
{ __( 'Mobile' ) }
</MenuItem>
</MenuGroup>
{ children( renderProps ) }
{ children?.( renderProps ) }
</>
) }
</DropdownMenu>
Expand Down

0 comments on commit c04e420

Please sign in to comment.