An easier way to add types for "children" in React
Something I had been struggling with since I started using React up until a few months ago was finding a good type to set for the children prop.
The typical route I would take is to sorta just add the types as I needed them to a union like so:
interf...
·4 min read·ozzie.shRead the article
shadowtime2000
You could also do
import type { PropsWithChildren } from "react";because it's easier for build tools to know it's a type import so they can remove it without ruining the output of the code.