Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
React and React Native

You're reading from   React and React Native Build cross-platform JavaScript applications with native power for the web, desktop, and mobile

Arrow left icon
Product type Paperback
Published in May 2022
Publisher Packt
ISBN-13 9781803231280
Length 606 pages
Edition 4th Edition
Languages
Tools
Arrow right icon
Authors (3):
Arrow left icon
Roy Derks Roy Derks
Author Profile Icon Roy Derks
Roy Derks
Mikhail Sakhniuk Mikhail Sakhniuk
Author Profile Icon Mikhail Sakhniuk
Mikhail Sakhniuk
Adam Boduch Adam Boduch
Author Profile Icon Adam Boduch
Adam Boduch
Arrow right icon
View More author details
Toc

Table of Contents (36) Chapters Close

Preface 1. Part 1 – React
2. Chapter 1: Why React? FREE CHAPTER 3. Chapter 2: Rendering with JSX 4. Chapter 3: Component Properties, State, and Context 5. Chapter 4: Getting Started with Hooks 6. Chapter 5: Event Handling, the React Way 7. Chapter 6: Crafting Reusable Components 8. Chapter 7: The React Component Life Cycle 9. Chapter 8: Validating Component Properties 10. Chapter 9: Handling Navigation with Routes 11. Chapter 10: Code Splitting Using Lazy Components and Suspense 12. Chapter 11: Server-Side React Components 13. Chapter 12: User Interface Framework Components 14. Chapter 13: High-Performance State Updates 15. Part 2 – React Native
16. Chapter 14: Why React Native? 17. Chapter 15: React Native under the Hood 18. Chapter 16: Kick-Starting React Native Projects 19. Chapter 17: Building Responsive Layouts with Flexbox 20. Chapter 18: Navigating Between Screens 21. Chapter 19: Rendering Item Lists 22. Chapter 20: Showing Progress 23. Chapter 21: Geolocation and Maps 24. Chapter 22: Collecting User Input 25. Chapter 23: Displaying Modal Screens 26. Chapter 24: Responding to User Gestures 27. Chapter 25: Using Animations 28. Chapter 26: Controlling Image Display 29. Chapter 27: Going Offline 30. Chapter 28: Selecting Native UI Components Using NativeBase 31. Part 3 – React Architecture
32. Chapter 29: Handling Application State 33. Chapter 30: Why GraphQL? 34. Chapter 31: Building a GraphQL React App 35. Other Books You May Enjoy

Batching state updates

In this section, you'll learn about how React can batch state updates together in order to prevent unnecessary rendering when multiple state changes happen at the same time. In particular, we'll look at the changes introduced in React 18 that make automatic batching of state updates commonplace.

When your React component issues a state change, this causes the React internals to re-render the parts of your component that have changed visually as a result of this state update. For example, imagine you have a component with a name state that's rendered inside of a <span> element and you change the name state from Adam to Ashley. That's a straightforward change that results in a re-render that's too fast for the user to even notice. Unfortunately, state updates in web applications are rarely this straightforward. Instead, there might be dozens of state changes in 10 milliseconds. For example, the name state might follow changes like...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime