Typing Components
Props are just an object type, and typing them is nearly all there is to TypeScript in React.
The callback props are where the compiler earns its keep: passing the wrong argument to onSelect becomes a compile error rather than a runtime surprise three components away.
A few React-specific types.
React.ReactNode for anything renderable, which is what children usually is.
React.ChangeEvent<HTMLInputElement> for an input's change handler.
React.FormEvent for a submit handler.
useRef<HTMLInputElement>(null) so .current.focus() checks.
React.FC is no longer recommended. Type the props parameter directly.
Mark this lesson complete
Signed in, your progress follows you to every device.