1
2interface PersonProps {
3 name: string;
4 age: number;
5 hobbies: Array<string>;
6 isCool: boolean;
7}
8
9// Boolean type
10const [isCool] = React.useState<boolean>(true);
11
12// String type
13const [name] = React.useState<string>('Ruben');
14
15// Number type
16const [age] = React.useState<number>(28);
17
18// Null or undefined
19const [random] = React.useState<null | undefined>();
20
21// Array of string
22const [hobbies] = React.useState<Array<string>>(['soccer', 'cooking', 'code']);
23
24// Custom interface
25const [person] = React.useState<PersonProps>({
26 isCool,
27 name,
28 age,
29 hobbies
30});
31