Nono.MA

Three ways to define a functional React component in TypeScript

APRIL 13, 2023

Here are three ways to define a React component in TypeScript which, in the end, are three ways to define a function in TypeScript—React components are JavaScript functions.

const MyComponent = (text: string) => <>{text}</>
const MyComponent = (text: string) => {
  return (
    <>{text}</>
  )
}
function MyComponent(text: string) {
  return <>{text}</>
}

BlogCodeTypescriptReact