Skip to content

This repository contains all the code examples and exercises from the book "Learn React with TypeScript - Second Edition" by Carl Rippon, published by Packt Publishing. It serves as a comprehensive learning resource for developers who want to build modern, type-safe web applications using React 18 and TypeScript.

License

Notifications You must be signed in to change notification settings

GizzZmo/Learn-React-with-TypeScript-2nd-Edition

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

50 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Learn React with TypeScript - Second Edition

GitHub stars GitHub forks License: MIT PRs Welcome

Learn React with TypeScript - Second Edition

This is the code repository for Learn React with TypeScript - Second Edition, published by Packt.

A beginner's guide to reactive web development with React 18 and TypeScript

πŸ“š View detailed information about this repository β†’

Table of Contents

What is this book about?

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 book covers the following exciting features:

  • Gain first-hand experience of TypeScript and its productivity features
  • Understand how to transpile your TypeScript code into JavaScript for running in a browser
  • Build a React frontend codebase with hooks
  • Interact with REST and GraphQL web APIs
  • Design and develop strongly typed reusable components
  • Create automated component tests

If you feel this book is for you, get your copy today!

πŸ“š Documentation

This repository includes comprehensive documentation to help you learn and use the examples:

  • ABOUT.md - Detailed information about this repository, learning paths, and contribution guidelines
  • QUICK_START.md - Get started quickly with installation, running examples, and troubleshooting
  • EXAMPLES.md - Complete guide to all examples in this repository
  • Chapter READMEs - Detailed documentation for each chapter (see below)

πŸš€ Getting Started

New to the repository? Here's your path to success:

  1. Learn About This Project: Read the ABOUT.md for context and learning paths
  2. Quick Start: Follow the QUICK_START.md guide for immediate setup
  3. Browse Examples: Check out EXAMPLES.md for a complete overview
  4. Explore Chapters: Navigate to any chapter folder and read its README
  5. Join the Community: Star the repo and engage in discussions

Prerequisites

  • Node.js (v16.0.0 or later)
  • npm or yarn
  • Basic knowledge of JavaScript and HTML/CSS

Running an Example

# Navigate to any chapter example
cd Chapter4/Section1-Using-the-effect-hook

# Install dependencies
npm install

# Start the development server
npm start

πŸ“– Chapter Guide

Each chapter has its own comprehensive README with detailed explanations, code examples, and best practices:

Chapter Topic README
Chapter 1 Introducing React View README
Chapter 2 Introducing TypeScript View README
Chapter 3 Setting Up React and TypeScript View README
Chapter 4 Using React Hooks View README
Chapter 5 Approaches to Styling React Components View README
Chapter 6 Routing with React Router View README
Chapter 7 Working with Forms View README
Chapter 8 State Management View README
Chapter 9 Interacting with RESTful APIs View README
Chapter 10 Interacting with GraphQL APIs View README
Chapter 11 Reusable Components View README
Chapter 12 Unit Testing with Jest and React Testing Library View README

Instructions and Navigations

All of the code is organized into folders. For example, Chapter02.

The code will look like the following:

class Product {
  constructor(public name: string, public unitPrice:
    number) {
    this.name = name;
    this.unitPrice = unitPrice;
  }
}

πŸ’‘ What You'll Learn

By working through the examples in this repository, you'll learn:

  • React Fundamentals: Components, JSX, props, state, and events
  • TypeScript Basics: Types, interfaces, generics, and type safety
  • React Hooks: useState, useEffect, useContext, and custom hooks
  • Styling: CSS, CSS Modules, CSS-in-JS, and Tailwind CSS
  • Routing: React Router for multi-page applications
  • Forms: Controlled/uncontrolled components and validation
  • State Management: Context API and Redux
  • Data Fetching: REST APIs with fetch and React Query
  • GraphQL: Apollo Client and GraphQL queries/mutations
  • Reusable Components: Generic props, render props, and custom hooks
  • Testing: Jest and React Testing Library

Following is what you need for this book: This book is for experienced frontend developers looking to build large scale web applications using React and TypeScript. Intermediate knowledge of JavaScript, HTML and CSS is a prerequisite.

With the following software and hardware list you can run all code files present in the book (Chapter 1-12).

Software and Hardware List

Chapter Software/Hardware required OS required
1-12 Google Chrome Windows, Mac OS X, and Linux
1-12 Node.js and npm Windows, Mac OS X, and Linux
1-12 Visual Studio Code Windows, Mac OS X, and Linux
1-12 React 18.0 or later Windows, Mac OS X, and Linux
1-12 TypeScript 4.7 or later Windows, Mac OS X, and Linux

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. Click here to download it.

Errata

  • Page 137: In Step 7, React.tsx should be Reset.tsx
  • Page 302, In Step 5,
if '!('ti'le' in post)) {
  throw new Err"r("post do'sn't contain ti"le");
}
if (typeof post.title !'= 'str'ng') {
  throw new Err'r('title is not a str'ng');
}
if '!('descript'on' in post)) {
  throw new Err"r("post do'sn't contain descript"on");
}
if (typeof post.description !'= 'str'ng') {
  throw new Err'r('description is not a str'ng');
}

should be

if (!("title" in post)) {
  throw new Error("post doesn't contain title");
}
if (typeof post.title !== "string") {
  throw new Error("title is not a string");
}
if (!("description" in post)) {
  throw new Error("post doesn't contain description");
}
if (typeof post.description !== "string") {
  throw new Error("description is not a string");
}

🀝 Contributing

Found an issue or have a suggestion? Contributions are welcome!

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/improvement)
  3. Commit your changes (git commit -am 'Add new feature')
  4. Push to the branch (git push origin feature/improvement)
  5. Open a Pull Request

πŸ“š Additional Resources

Related products

πŸ™ Acknowledgments

This repository and the accompanying book would not be possible without:

  • The React Team at Meta for creating and maintaining React
  • The TypeScript Team at Microsoft for TypeScript
  • The Open Source Community for the incredible ecosystem of tools and libraries
  • All Contributors who have helped improve this repository
  • Packt Publishing for supporting this project
  • Readers and Learners who provide feedback and help make this resource better

Special thanks to everyone who has starred, forked, or contributed to this repository!

Get to Know the Author

Carl Rippon has been in the software industry for over 20 years developing complex lines of business applications in various sectors. He has spent the last 8 years building single-page applications using a wide range of JavaScript technologies including Angular, ReactJS, and TypeScript. He has also written over 100 blog posts on various technologies.

Other books by the author

Download a free PDF

If you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost.
Simply click on the link to claim your free PDF.

https://packt.link/free-ebook/9781804614204

πŸ’¬ Support

Getting Help

Stay Connected

If you find this repository helpful:

  1. ⭐ Star the repository to show your support
  2. πŸ‘οΈ Watch for updates and new content
  3. 🍴 Fork to create your own version
  4. πŸ“’ Share with others who might benefit

Made with ❀️ by the React and TypeScript community

Happy coding! πŸš€

About

This repository contains all the code examples and exercises from the book "Learn React with TypeScript - Second Edition" by Carl Rippon, published by Packt Publishing. It serves as a comprehensive learning resource for developers who want to build modern, type-safe web applications using React 18 and TypeScript.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 62.6%
  • HTML 20.8%
  • CSS 12.6%
  • JavaScript 4.0%