Lesson 29 of 56
TypescriptReact Hooks – `useState`, `useEffect` Types
20 minutes
Course progress52%
useState
const [items, setItems] = useState<string[]>([]);
When initializing with a function, provide a generic:
const [count, setCount] = useState(() => computeInitial());