Skip to content

Commit c855b36

Browse files
authored
add some notes for React.useState
1 parent b9e3bd8 commit c855b36

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Diff for: README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,15 @@ export interface Props {
439439

440440
## Hooks
441441

442-
*Not written yet.*
442+
Hooks are supported in `@types/react` from v16.7 up.
443+
444+
Many hooks are initialized with null-ish default values, and you may wonder how to provide types. Do this:
445+
446+
```tsx
447+
const [user, setUser] = useState<IUser | null>(null);
448+
```
449+
450+
If you are writing a React Hooks library, don't forget that you can also expose
443451

444452
[Something to add? File an issue](https://github.com/sw-yx/react-typescript-cheatsheet/issues/new).
445453

0 commit comments

Comments
 (0)