Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learn React Hooks

You're reading from  Learn React Hooks

Product type Book
Published in Oct 2019
Publisher Packt
ISBN-13 9781838641443
Pages 426 pages
Edition 1st Edition
Languages
Author (1):
Daniel Bugl Daniel Bugl
Profile icon Daniel Bugl

Table of Contents (19) Chapters

Preface 1. Section 1: Introduction to Hooks
2. Introducing React and React Hooks 3. Using the State Hook 4. Writing Your First Application with React Hooks 5. Section 2: Understanding Hooks in Depth
6. Using the Reducer and Effect Hooks 7. Implementing React Context 8. Implementing Requests and React Suspense 9. Using Hooks for Routing 10. Using Community Hooks 11. Rules of Hooks 12. Building Your Own Hooks 13. Section 3: Integration and Migration
14. Migrating from React Class Components 15. Redux and Hooks 16. MobX and Hooks 17. Assessments 18. Other Books You May Enjoy

Comparing our reimplementation with real Hooks

Our simple Hook implementation already gives us an idea about how Hooks work internally. However, in reality, Hooks do not use global variables. Instead, they store state within the React component. They also deal with the Hook counter internally, so we do not need to manually reset the count in our function component. Furthermore, real Hooks automatically trigger rerenders of our component when the state changes. To be able to do this, however, Hooks need to be called from a React function component. React Hooks cannot be called outside of React, or inside React class components.

By reimplementing the useState Hook, we have learned a couple things:

  • Hooks are simply functions that access React features
  • Hooks deal with side effects that persist across rerenders
  • The order of Hook definitions matters

The last point is especially important...

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 $15.99/month. Cancel anytime}