Rodrigo
Rodrigo

Reputation: 301

Typing a functional component react using typescript

I want to change this anon. function

const Button: React.FunctionComponent = ({ children }: Props) => { })

to function signature

function Button() { }

But how can I insert the type React.FunctionComponent on function version?

Upvotes: 0

Views: 127

Answers (1)

Sakshi
Sakshi

Reputation: 1548

You can write it like this:

interface DummyProps{
property1:string //here instead of property1 you can name it whatever you want to and its type can be anything.For example i have used here string
}

export default ({property1}:DummyProps) => {
return (
       <div>
           {property1}
       </div>
   );
}

Upvotes: 1

Related Questions