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

Typescript calling a function by reference inside of react jsx

$
0
0

I am using Typescript with React JS.

let's say if I have a React functional component:

function MyFunction(){      const myArrowFunction = () =>{          return(<div><p>Some Paragraph</p></div>          );      };     //In JavaScript, I would do this to call it the function by reference and it works.     //In TypeScript, when I do the same, I do not see the "Some Paragraph" visible on the screen     return(<main>           {myArrowFunction}</main>     );}

calling the function with parenthesis works in Typescript:

return(<main>     {myArrowFunction()}</main>);

In JavaScript, I would do this {myArrowFunction} to call it the function by reference and it works.In TypeScript, when I do the same, I do not see the "Some Paragraph" visible on the screen

What is the best way to call a function by reference in Typescript?

Thanks.


Viewing all articles
Browse latest Browse all 6364

Trending Articles