Creating strongly-typed function component states with useState
In this lesson, we are going to learn how to create strongly-typed states in a function component with the 'useState' hook.
We'll cover the following
Inferred useState type #
The useState
hook allows us to create a single piece of state. Click the following link to open a CodeSandbox project that makes use of useState
:
CodeSandbox useState project 1
This is a React and TypeScript project containing a Counter
component with a piece of state called count
.
What type is the count
state?
Get hands-on with 1200+ tech skills courses.