PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.9.0
GenerateBlocks v1.9.0
trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.3.0
generateblocks / src / pattern-library / components / pattern-search.js
generateblocks / src / pattern-library / components Last commit date
add-library.js 2 years ago category-list.js 2 years ago insert-pattern.js 2 years ago library-cache.js 2 years ago library-layout.js 2 years ago library-provider.js 2 years ago library-selector.js 2 years ago manage-libraries.js 2 years ago pattern-details-header.js 2 years ago pattern-details.js 2 years ago pattern-list.js 2 years ago pattern-search.js 2 years ago pattern.js 2 years ago selected-patterns.js 2 years ago
pattern-search.js
25 lines
1 import { SearchControl } from '@wordpress/components';
2 import { useState, useEffect } from '@wordpress/element';
3 import { useDebounce } from '@wordpress/compose';
4 import { useLibrary } from './library-provider';
5
6 export default function PatternSearch( { onChange } ) {
7 const { setSearch } = useLibrary();
8 const [ searchInput, setSearchInput ] = useState( '' );
9 const setDebouncedInput = useDebounce( setSearch, 500 );
10
11 useEffect( () => {
12 setDebouncedInput( searchInput );
13 }, [ searchInput ] );
14
15 return (
16 <SearchControl
17 value={ searchInput }
18 onChange={ ( value ) => {
19 onChange( value );
20 setSearchInput( value );
21 } }
22 />
23 );
24 }
25