Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying React and React Native
  • Table Of Contents Toc
React and React Native

React and React Native - Sixth Edition

By : Mikhail Sakhniuk, Rodrigo Lobenwein, Adam Boduch
close
close
React and React Native

React and React Native

By: Mikhail Sakhniuk, Rodrigo Lobenwein, Adam Boduch

Overview of this book

Welcome to your big-picture guide to the React ecosystem. If you’re new to React and looking to become a professional React developer, this book is for you. This updated sixth edition reflects the current state of React, including coverage of React frameworks and TypeScript. Part 1 introduces you to React. You’ll discover JSX syntax, hooks, functional components, and event handling, learn techniques to fetch data from a server, and tackle the tricky problem of state management. Once you’re comfortable with writing React in JavaScript, you’ll pick up TypeScript development in later chapters. Part 2 transitions you into React Native for mobile development. React Native goes hand-in-hand with React. With your React knowledge in place, you’ll appreciate where and how React Native differs as you write shared components for Android and iOS apps. You’ll learn how to build responsive layouts, use animations, and implement geolocation. Finally, a new chapter shows you how to use AI as a learning partner, covering practical workflows for AI-assisted debugging, evaluating AI-generated code, recognizing common pitfalls in React and React Native output, and writing code deliberately to deepen your understanding. By the end of this book, you’ll have a big-picture view of React and React Native, and be able to build applications with both.
Table of Contents (35 chapters)
close
close
Lock Free Chapter
1
Part 1: React
16
Part 2: React Native
33
Other Books You May Enjoy
34
Index

Preface

Over the years, React and React Native have proven themselves as popular choices for building cross-platform applications. This sixth edition has been updated to cover React 19, the latest Expo SDK, and current best practices in the React ecosystem, including TypeScript, server-side rendering with Next.js, and modern state management.

From the basics of JSX and components to advanced topics such as Hooks, server rendering, code splitting, and unit testing, this guide will help you become a confident React developer in a step-by-step manner.

You'll begin by learning the essential building blocks of React components. Next, you'll learn how to improve the reliability of your code using TypeScript. As you advance through the chapters, you'll work with routing, data fetching, state management, and server-side rendering, then put your knowledge to work by developing applications for web and mobile platforms with React Native. This edition also includes a new chapter on using AI as a learning partner.

By the end of this book, you'll be able to build React applications for the web and React Native applications for mobile with confidence.

Who this book is for

This book is for any JavaScript developer who wants to start learning how to use React and React Native for mobile and web application development. No prior knowledge of React is required; however, working knowledge of JavaScript, HTML and CSS is necessary to be able to follow along with the content covered.

What this book covers

Chapter 1, Why React?, describes what React is and why you want to use it to build your application.

Chapter 2, Rendering with JSX, teaches the basics of JSX, the markup language used by React components.

Chapter 3, Understanding React Components and Hooks, introduces the core mechanisms of components and Hooks in React applications.

Chapter 4, Event Handling in the React Way, gives an overview of how events are handled by React components.

Chapter 5, Crafting Reusable Components, guides you through the process of refactoring components by example.

Chapter 6, Type-Checking and Validation with TypeScript, describes the various phases that React components go through and why it's important for React developers.

Chapter 7, Handling Navigation with Routes, provides plenty of examples of how to set up routing for your React web app.

Chapter 8, Code Splitting Using Lazy Components and Suspense, introduces code-splitting techniques that result in performant, more efficient applications.

Chapter 9, User Interface Framework Components, gives an overview of how to get started with MUI, a React component library for building UIs.

Chapter 10, High-Performance State Updates, goes into depth on the new features in React that allow for efficient state updates and a high-performing application.

Chapter 11, Fetching Data from a Server, discusses how we can retrieve the data from servers using various methods.

Chapter 12, State Management in React, covers managing state in the app with popular solutions like Redux and Mobx.

Chapter 13, Server-Side Rendering, teaches you how to use Next.js to build large-scale React applications that render content on a server and a client.

Chapter 14, Unit Testing in React, gives an overview of testing software with a focus on unit testing using Vittest.

Chapter 15, Why React Native?, describes what the React Native library is and the differences between native mobile development.

Chapter 16, React Native Under the Hood, gives an overview of the architecture of React Native.

Chapter 17, Kick-Starting React Native Projects, teaches you how to start a new React Native project.

Chapter 18, Building Responsive Layouts with Flexbox, describes how to create a layout and add styles.

Chapter 19, Navigating Between Screens, shows the approaches to switching between screens in an app.

Chapter 20, Rendering Item Lists, describes how to implement lists of data in an application.

Chapter 21, Geolocation and Maps, explains how to track geolocation and add a map to an app.

Chapter 22, Collecting User Input, teaches you how to create forms.

Chapter 23, Responding to User Gestures, provides examples of how to handle user gestures.

Chapter 24, Showing Progress, shows you how to handle process indications and progress bars.

Chapter 25, Displaying Modal Screens, teaches you how to create dialog modals.

Chapter 26, Using Animations, describes how to implement animations in an app.

Chapter 27, Controlling Image Display, gives an overview of how to render images in a React Native app.

Chapter 28, Going Offline, shows how to deal with an app when a mobile phone doesn't have an internet connection.

Chapter 29, AI as a Learning Partner, explores how to use AI tools effectively for learning, debugging, and improving your React and React Native code while avoiding common pitfalls.

To get the most out of this book

This book assumes you have a basic understanding of the JavaScript programming language. It also assumes that you'll be following along with the examples, which require a command-line terminal, a code editor, and a web browser. You'll learn how to set up a React project in Chapter 1, Why React?.

The requirements for learning React Native are the same as for React development, but to run an app on a real device, you will need an Android or iOS smartphone. In order to run iOS apps in the simulator, you will need a Mac computer. To work with the Android simulator, you can use any kind of PC.

Download the example code files

The code bundle for the book is hosted on GitHub at https://github.com/PacktPublishing/React-and-React-Native-6E. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://packt.link/gbp/9781837020294.

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. For example: "The createRoot function tells React to take your JSX markup and update the UI."

A block of code is set as follows:

const MyComponent = ({ title, description }) => {
  return (
    <div>
      <h1>{title}</h1>
      <p>{description}</p>
    </div>
  );
};

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center",
  },
  text: { fontWeight: "bold" },
});

Any command-line input or output is written as follows:

npm install

Bold: Indicates a new term, an important word, or words that you see on the screen. For instance, words in menus or dialog boxes appear in the text like this. For example: "Events: These are the code that we write to respond to user interactions".

Warnings or important notes appear like this.

Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book or have any general feedback, please email us at customercare@packt.com and mention the book's title in the subject of your message.

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you reported this to us. Please visit http://www.packt.com/submit-errata, click Submit Errata, and fill in the form.

Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit http://authors.packt.com/.

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
React and React Native
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist download Download options font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon