File size: 715 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { FormTokenField } from '@wordpress/components';
import { withState } from '@wordpress/compose';

type TokenValue = React.ComponentProps< typeof FormTokenField >[ 'value' ];

const FormTokenFieldExample = withState( {
	tokens: [],
	suggestions: [
		'Africa',
		'North America',
		'South America',
		'Antarctica',
		'Asia',
		'Europe',
		'Oceania',
	],
} )(
	( {
		tokens,
		suggestions,
		setState,
	}: {
		tokens: string[];
		suggestions: string[];
		setState: ( { tokens }: { tokens: TokenValue } ) => void;
	} ) => (
		<FormTokenField
			value={ tokens }
			suggestions={ suggestions }
			onChange={ ( nextTokens ) => setState( { tokens: nextTokens } ) }
		/>
	)
);

export default FormTokenFieldExample;