function components typescript code example
Example: How to use Function Components in React TypeScript
import React from "react";
type Props = {
linkFirst: string,
routeFirst: string,
head?: string,
linkSecond?: string,
routeSecond?: string
};
const DefaultProps = {
head: "Navbar Head not found"
};
const Navbar: React.FC <Props> = (props) => {
return (
<div>
<nav>
{ props.head }
<ul>
<li>
<a href={ props.routeFirst }> {props.linkFirst} </a>
<li>
<a href= { props.routeSecond }> {props.linkSecond} </a>
</li>
</ul>
</nav>
</div>
);
};
Navbar.defaultProps = DefaultProps;
export default Navbar;