Hook that is initialized with an empty array?

Viewed 39

Let's say we want to make Hook with type string[], and no elements. I am doing

const def: string[] = []
const [selected, setSelected] = useState(def);

Which works. But, I was wondering if there is a way to achieve this in one line only.

1 Answers
const [selected, setSelected] = useState<string[]>([]);
Related