Skip to content

Commit

Permalink
Update examples to use store export based on #52189
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanwelcher committed Jun 30, 2023
1 parent af6e01f commit b99e878
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions docs/reference-guides/data/data-core-customize-widgets.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ Returns true if the inserter is opened.
_Usage_

```js
import { store as customizeWidgetsStore } from '@wordpress/customize-widgets';
import { __ } from '@wordpress/i18n';
import { useSelect } from '@wordpress/data';

const ExampleComponent = () => {
const { isInserterOpened } = useSelect(
( select ) => select( 'core/customize-widgets' ),
( select ) => select( customizeWidgetsStore ),
[]
);

Expand Down Expand Up @@ -49,13 +50,14 @@ Returns an action object used to open/close the inserter.
_Usage_

```js
import { store as customizeWidgetsStore } from '@wordpress/customize-widgets';
import { __ } from '@wordpress/i18n';
import { useDispatch } from '@wordpress/data';
import { Button } from '@wordpress/components';
import { useState } from '@wordpress/element';

const ExampleComponent = () => {
const { setIsInserterOpened } = useDispatch( 'core/customize-widgets' );
const { setIsInserterOpened } = useDispatch( customizeWidgetsStore );
const [ isOpen, setIsOpen ] = useState( false );

return (
Expand Down
3 changes: 2 additions & 1 deletion packages/customize-widgets/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
*
* @example
* ```js
* import { store as customizeWidgetsStore } from '@wordpress/customize-widgets';
* import { __ } from '@wordpress/i18n';
* import { useDispatch } from '@wordpress/data';
* import { Button } from '@wordpress/components';
* import { useState } from '@wordpress/element';
*
* const ExampleComponent = () => {
* const { setIsInserterOpened } = useDispatch( 'core/customize-widgets' );
* const { setIsInserterOpened } = useDispatch( customizeWidgetsStore );
* const [ isOpen, setIsOpen ] = useState( false );
*
* return (
Expand Down
5 changes: 3 additions & 2 deletions packages/customize-widgets/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@
*
* @example
* ```js
* import { store as customizeWidgetsStore } from '@wordpress/customize-widgets';
* import { __ } from '@wordpress/i18n';
* import { useSelect } from '@wordpress/data';
*
* const ExampleComponent = () => {
* const { isInserterOpened } = useSelect(
* ( select ) => select( 'core/customize-widgets' ),
* ( select ) => select( customizeWidgetsStore ),
* []
* );
*
* return isInserterOpened()
* ? __( 'Inserter is open' )
* : __( 'Inserter is closed.' );
* };
* };
* ```
*
* @return {boolean} Whether the inserter is opened.
Expand Down

0 comments on commit b99e878

Please sign in to comment.