Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6363

What's the type of a arrow function (or a normal function) in typescript?

$
0
0

So, I'm trying to type the props of a component

interface CardProps {  title: string;  content: string;  image?: string;  handle: Function;}const Card: React.FC<CardProps> = ({ title, content, handle, image }: any) => {  return (<CardContainer onPress={handle}>{/*...*/}  )

But when I run it, it gives me a error:Don't use 'Function' as a type. The 'Function' type accepts any function-like value. It provides no type safety when calling the function, which can be a common source of bugs. It also accepts things like class declarations, which will throw at runtime as they will not be called with 'new'. If you are expecting the function to accept certain arguments, you should explicitly define the function shape.

The handle is like this

<Card    {/*👇*/}        handle={() =>          navigation.navigate("Verbete", {            title: verbetes.nazismo.title,            content: verbetes.nazismo.content,          })      />

I want to know what is the type of a function


Viewing all articles
Browse latest Browse all 6363

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>