Joel M. Turner

Illustration

Blog

Notes

~/notes//*/

react-typescript

Helpful React Types

Hooks

1// add type before parens
2React.useState<boolean>(false);
3React.useRef<HTMLDivElement>(null);

Props

1type FooProps = {
2 children: React.ReactNode;
3 }

Components

1// functional
2const Foo: React.FC<FooProps> = (props) => ()
3// class
4class Foo extends React.Component<FooProps> {}

emotion

1const Foo = styled<FooProps>.div``;