Book description
Build stylish, slick, and speedy-to-load user interfaces in React without writing custom classes. React Hooks are a new category of functions that help you to manage state, lifecycle, and side effects within functional components. React Hooks in Action teaches you to use pre-built hooks like useState, useReducer and useEffect to build your own hooks. Your code will be more reusable, require less boilerplate, and you’ll instantly be a more effective React developer.About the Technology
Get started with React Hooks and you’ll soon have code that’s better organized and easier to maintain. React Hooks are targeted JavaScript functions that let you reuse and share functionality across components. Use them to split components into smaller functions, manage state and side effects, and access React features without classes—all without having to rearrange your component hierarchy.
About the Book
React Hooks in Action teaches you to write fast and reusable React components using Hooks. You’ll start by learning to create component code with Hooks. Next, you’ll implement a resource booking application that demonstrates managing local state, application state, and side effects like fetching data. Code samples and illustrations make learning Hooks easy.
What's Inside
- Build function components that access React features
- Manage local, shared, and application state
- Explore built-in, custom, and third-party hooks
- Load, update, and cache data with React Query
- Improve page and data loading with code-splitting and React Suspense
About the Reader
For beginning to intermediate React developers.
About the Author
John Larsen has been a teacher and web developer for over 20 years, creating apps for education and helping students learn to code. He is the author of Get Programming with JavaScript.
Quotes
Discover React Hooks, and the future of developing apps with React. A great book.
- Arnaud Castelltort, University of Montpellier
This book covers everything that you need to know. A fantastic addition to your React arsenal.
- Clive Harber, Distorted Thinking Ltd.
Level up your React knowledge and take advantage of the newer features and best practices.
- Ryan Burrows, Remitly
An excellent introduction. Filled with knowledge nuggets and real-world use cases.
- Edin Kapić, isolution
Table of contents
- React Hooks in Action
- Copyright
- dedication
- contents
- front matter
- Part 1
- 1 React is evolving
-
2 Managing component state with the useState hook
- 2.1 Setting up the bookings manager app
-
2.2 Storing, using, and setting values with useState
- 2.2.1 Assigning new values to variables doesn’t update the UI
- 2.2.2 Calling useState returns a value and an updater function
- 2.2.3 Calling the updater function replaces the previous state value
- 2.2.4 Passing a function to useState as the initial value
- 2.2.5 Using the previous state when setting the new state
- 2.3 Calling useState multiple times to work with multiple values
- 2.4 Reviewing some function component concepts
- Summary
- 3 Managing component state with the useReducer hook
-
4 Working with side effects
-
4.1 Exploring the useEffect API with simple examples
- 4.1.1 Running side effects after every render
- 4.1.2 Running an effect only when a component mounts
- 4.1.3 Cleaning up side effects by returning a function
- 4.1.4 Controlling when an effect runs by specifying dependencies
- 4.1.5 Summarizing the ways to call the useEffect hook
- 4.1.6 Calling useLayoutEffect to run an effect before the browser repaints
- 4.2 Fetching data
- 4.3 Fetching data for the BookablesList component
- Summary
-
4.1 Exploring the useEffect API with simple examples
- 5 Managing component state with the useRef hook
- 6 Managing application state
- 7 Managing performance with useMemo
- 8 Managing state with the Context API
- 9 Creating your own hooks
- 10 Using third-party hooks
- Part 2
- 11 Code splitting with Suspense
- 12 Integrating data fetching with Suspense
- 13 Experimenting with useTransition, useDeferredValue, and SuspenseList
- index
Product information
- Title: React Hooks in Action
- Author(s):
- Release date: April 2021
- Publisher(s): Manning Publications
- ISBN: 9781617297632
You might also like
book
Learn React Hooks
Create large-scale web applications with code that is extensible and easy to understand using React Hooks …
video
React Hooks Tips Only the Pros Know
Are you loving React but new to the Hooks API? Are you already using React Hooks …
video
The Complete React Developer Course (with Hooks and Redux)
The Complete React Developer Course (with Hooks and Redux) starts with the fundamentals and covers everything …
video
React Front to Back 2022
The course starts with React fundamentals including components, props, hooks, state, and so on. Then learn …