const Title = () => {
return <div>Title</div>;
};
- React.FC 는 React.FunctionComponent 의 축약형
- 자동으로 children 타입을 지정해준다.
interface TitleProps {
age: number;
job: string;
city: string;
children?: React.ReactNode;
}
const Title: React.FC<TitleProps> = ({ age, job, city, children }) => {
return (
<div>
Title {age} {job} {children} {city}
</div>
);
};
- JSX.Element
- 자동으로 children 속성을 제공하지 않는다.
interface TitleProps {
age: number;
job: string;
city: string;
children?: React.ReactNode;
}
const Title = ({ age, job, children, city }: TitleProps): JSX.Element => {
return (
<div>
Title {age} {job} {children} {city}
</div>
);
};
interface TitleProps {
age: number;
job: string;
city: string;
children?: React.ReactNode;
}
const Title: React.FC = (): JSX.Element => {
return <div>Title</div>;
};