// 1. The Classic Way
export default function CompName(){return (<>...</>)}
// 2. The Cool Short Way
const CompName = () => {return (<>...</>)}
// 3. The Old TypeScript Way
const CompName: React.FunctionComponent<{ message: string }> = ({ message }) => ( <div>{message}</div> );
// 4.Short version of #3
const CompName: React.FC<AppProps> = ({ message }) => <div>{message}</div>;
Think of it like introducing yourself...
Imagine you're telling someone your name. You can say it in different ways:
"Hi, I'm Pramod!"
"My name is Pramod"
"You can call me Pramod"
They all mean the same thing, but some ways feel more natural!
The 4 Ways Explained
1οΈβ£ export default function CompName() β The Classic Way
export default function CompName() {
return <div>Hello!</div>
}
Like saying "Hi, I'm Pramod!" β clear, simple, everyone understands it instantly.
β
Best for pages and big components
β
Easiest to read
β
Works great in .jsx and .tsx
2οΈβ£ const CompName = () => β The Cool Short Way
const CompName = () => {
return <div>Hello!</div>
}
Like saying "Call me Pramod" β a bit shorter, still totally fine.
β
Popular in modern React
β οΈ Can't be used before it's written in the file (unlike #1)
3οΈβ£ React.FunctionComponent<{message: string}> β The Old TypeScript Way
const CompName: React.FunctionComponent<{ message: string }> = ({ message }) => (
<div>{message}</div>
);
Like wearing a name tag with your full title β "Hello, my name is Pramod Kumar Boda" π
β React team says don't use this anymore
β It used to auto-include children prop (caused bugs!)
β Too verbose
4οΈβ£ React.FC<AppProps> β Short version of #3
const CompName: React.FC<AppProps> = ({ message }) => <div>{message}</div>;
Same as #3, just shorter. Still the same problems.
β Also not recommended anymore (same reasons)
π Expert Answer: Use #1 or #2
| Situation | Use This |
|---|---|
| Pages, big components | #1 function CompName()
|
| Small utility components | #2 const CompName = () =>
|
| TypeScript props? | Just define a separate type or interface |
The Expert TypeScript way today π
// Define props separately (clean!)
type ButtonProps = {
label: string;
onClick: () => void;
}
// Use #1 or #2 β NOT React.FC
export default function Button({ label, onClick }: ButtonProps) {
return <button onClick={onClick}>{label}</button>
}
Simple rule: Just avoid React.FC and React.FunctionComponent β they're old habits. Use plain functions with typed props instead! π
United States
NORTH AMERICA
Related News
π I Built a Dropshipping Automation Pipeline β Here's What I Learned (and What I'd Do Differently)
10h ago
How I Cut My LLM API Bill by 40x: A Freelancer's Migration Story
10h ago

Mattress Firm Coupons: Save up to $600
3h ago
Google Ordered to Pay $2 Billion For Anti-Competitive Practices By Swedish Court
20h ago
The Censorship Wall: Why Every AI Companion App Ends Up Filtering You
20h ago