Thursday, February 16, 2023

What is FC or function component in React ?

"FC" stands for "Functional Component". In React with TypeScript, a functional component is defined as a function that takes in props and returns JSX elements. The type of a functional component is typically defined using the FC type, which is short for FunctionComponent. For example, here's how you might define a functional component using FC in React with TypeScript:
In this example, MyComponent is a functional component that takes in name and age props of type string and number, respectively. The FC type definition at the top of the component definition tells TypeScript that this is a functional component that takes in props of type Props.

No comments:

Post a Comment