Book Image

Learn React with TypeScript - Second Edition

By : Carl Rippon
4.4 (8)
Book Image

Learn React with TypeScript - Second Edition

4.4 (8)
By: Carl Rippon

Overview of this book

Reading, navigating, and debugging a large frontend codebase is a major issue faced by frontend developers. This book is designed to help web developers like you learn about ReactJS and TypeScript, both of which power large-scale apps for many organizations. This second edition of Learn React with TypeScript is updated, enhanced, and improved to cover new features of React 18 including hooks, state management libraries, and features of TypeScript 4. The book will enable you to create well-structured and reusable React components that are easy to read and maintain, leveraging modern design patterns. You’ll be able to ensure that all your components are type-safe, making the most of TypeScript features, including some advanced types. You’ll also learn how to manage complex states using Redux and how to interact with a GraphQL web API. Finally, you’ll discover how to write robust unit tests for React components using Jest. By the end of the book, you’ll be well-equipped to use both React and TypeScript.
Table of Contents (19 chapters)
1
Part 1: Introduction
6
Part 2: App Fundamentals
10
Part 3: Data
14
Part 4: Advanced React

What this book covers

Chapter 1, Introducing React, covers the fundamentals of building React components. This includes defining component output using JSX, making a component configurable using props, and making a component interactive using states.

Chapter 2, Introducing TypeScript, is all about the fundamentals of TypeScript and its type system. This includes using inbuilt types, as well as creating new types.

Chapter 3, Setting Up React and TypeScript, explains how to create a project for React and TypeScript development. The chapter then moves on to how to create React components that use TypeScript to make props and states type-safe.

Chapter 4, Using React Hooks, details the common React hooks and their typical use cases. The chapter also covers how to use the hooks with TypeScript to make them type-safe.

Chapter 5, Approaches to Styling React Frontends, walks through how to style React components using several different approaches. The benefits of each approach are also explored.

Chapter 6, Routing with React Router, introduces a popular library that provides client-side routing for applications with multiple pages. It covers how to declare the paths for the pages and how to create links between them. It also covers how to implement page parameters for highly dynamic pages.

Chapter 7, Working with Forms, explores how forms can be implemented using several different approaches, including the use of a popular library. The benefits of each approach are also included.

Chapter 8, State Management, walks through how states can be shared between different components. Several approaches are explored, along with their benefits.

Chapter 9, Interacting with RESTful APIs, demonstrates how React components can interact with a REST API. The chapter steps through an approach using core React and then an alternative approach using a popular library.

Chapter 10, Interacting with GraphQL APIs, shows how React components can interact with a GraphQL API. The chapter details how this can be done using two different popular libraries.

Chapter 11, Reusable Components, brings in several patterns for making React components highly reusable but still type-safe.

Chapter 12, Unit Testing with Jest and React Testing Library, first delves into how functions can be tested with Jest. The chapter then moves on to how React components can be tested with the help of the React Testing Library.