Skip to content

TypeScript and React

React TypeScript Cheatsheets

React, JSDoc and JS

Return type

javascript - When to use JSX.Element vs ReactNode vs ReactElement? - Stack Overflow

JSX.Element or React.ReactElement?

React.ReactElement works for an array of functions??

React.ReactNode - type for children

Type of a React "callable"

interface ComponentProps {
    id: number;
}

const renderRoutes = (PassedComponent: React.ComponentType <ComponentProps>) => {
    return <PassedComponent
}

Click event

(event: React.MouseEvent<HTMLElement>) => void

Last update: 2023-04-24