Skip to Content
Learning TypeScript 2.x - Second Edition
book

Learning TypeScript 2.x - Second Edition

by Remo H. Jansen
April 2018
Beginner content levelBeginner
536 pages
13h 21m
English
Packt Publishing
Content preview from Learning TypeScript 2.x - Second Edition

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering TypeScript - Fourth Edition

Mastering TypeScript - Fourth Edition

Nathan Rozentals
Learning TypeScript

Learning TypeScript

Josh Goldberg
TypeScript for Beginners

TypeScript for Beginners

Bharath Thippireddy

Publisher Resources

ISBN: 9781788391474Supplemental Content