import { TextControl } from '@wordpress/components'; import { useMemo, useState } from 'react'; import Suggestions from '..'; export default function SuggestionsExample() { const [ query, setQuery ] = useState( '' ); const suggestions = useMemo( () => { if ( ! query ) { return []; } const allSuggestions = [ 'Foo', 'Bar', 'Baz' ].map( ( s ) => ( { label: s } ) ); const r = new RegExp( query, 'i' ); return allSuggestions.filter( ( { label } ) => r.test( label ) ); }, [ query ] ); return (
⚠️
The above input is for demonstration. It is not part of the{ ' ' }
{ ' component.
💡 Check your browser console to observe the `suggest` callback.