Functional stateless components

A functional stateless component (FSC) is a component that doesn't use an internal state, and it is a simple function, as opposed to a class that extends the Component class. For example, the Header component is an FSC:

import { Link } from "react-router-dom"; import * as React from "react"; type BgColor = "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light" | "dark" | "white"; interface HeaderProps { bg: BgColor; title: string; rootPath: string; links: { path: string; text: string }[]; } export const Header = (props: HeaderProps) => ( <nav className={`navbar navbar-expand-lg navbar-light bg-${props.bg}`}> <Link className="navbar-brand" to={props.rootPath}> {props.title} </Link> <ul ...

Get Learning TypeScript 2.x - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.