Generic useState type
Annotate nullable or union state explicitly.
tsxANYreacthookstypescriptuseState
tsx
const [user, setUser] = useState<User | null>(null);Notes
Useful when TypeScript cannot infer the full intended state type from the initializer.