React and Redux in Depth cover

React and Redux in Depth

Rating 4.2
Chapters
40
Series
Practical Series (HZ Books IT)
ISBN
9787111565635

Tags

Summary

React and Redux in Depth is a front-end engineering book by veteran architect Cheng Mo, published by China Machine Press in 2017. Its twelve chapters follow one thread—building a modern front-end project with React and Redux—and explain, from the ground up, the React mindset, component design, Redux data-flow management, and the engineering methods for combining the two into a complete application. It begins by initializing a React project, using JSX and Virtual DOM to show how React differs in approach from jQuery-style development; it then covers the difference between prop and state, the full component lifecycle of mounting, updating and unmounting, and how to design maintainable components. In the data-flow section, the book moves from the shortcomings of Flux to Redux, introducing Redux's basic principles, the division of labour between container components and dumb components, and the problem of connecting the two with React-Redux. On the practical side, it uses a built-in Todo application to work through modular code organization, state-tree design, combining reducers and development tools; it also systematically discusses component performance optimization, higher-order components and the function-as-child pattern, accessing the server in a React and Redux environment, asynchronous operations (redux-thunk, Promise), unit testing, middleware and Store Enhancer extensions, React animation, React-Router multi-page routing and code splitting, and isomorphic rendering on both server and browser. All examples are built with create-react-app, and components are written in ES6 syntax.

Editor's review

这是一本少见的“整本书都在讲整个工程怎么做”的React入门书。它没有停留在逐个API的罗列上,而是从“React和jQuery到底差在哪”这类问题讲起:先说清Virtual DOM和组件化带来的思维转变,再讲组件应该怎样划分、prop和state该由谁持有、生命周期函数在什么时机起作用。等读者对组件有了手感,书才引出Flux的不足和Redux的三大原则,把单向数据流讲成一套可操作的工程习惯。 全书最有价值的部分是“前后打通”:它把一个Todo应用从零写到能跑,再一路加码,做性能优化、高阶组件、异步请求、单元测试、中间件扩展、动画、路由与代码分片,最后落到同构渲染。读者会看到这些技术并不是孤立的知识点,它们都是同一个应用在变大之后自然遇到的难题。作者程墨是资深架构师,书中大量判断和取舍来自实战,例如“为什么不用ref”“状态树为什么要扁平”“冗余数据为什么危险”,这些都能直接迁移到真实项目里。 需要提醒的是,本书成书于2017年,示例基于类组件、create-react-app与当时的React-Router、Redux生态,如今已不是主流写法。但它讲的组件思维、单向数据流、状态设计与同构原理并不过时,把它当作“理解React工程化的第一本书”来读,收获会大于把它当作新版查询手册。

Who it's for

A good fit for

  • 有JavaScript与ES6基础,准备系统学习React的前端开发者
  • 做过jQuery或传统页面开发,想理解组件化与单向数据流的工程师
  • 需要在项目中引入Redux、并管理复杂状态的中级开发者
  • 想弄清前端测试、中间件、同构渲染等工程问题如何落地的人

Not a good fit for

  • 完全零编程经验的读者,书中不讲解JavaScript基础语法
  • 只想要最新版React Hooks与函数式组件速查手册的读者
  • 以React Native移动端开发为主要目标的读者

Reading tips

  1. 先读第1至第3章打牢组件与Redux数据流的底子,再进入第4章的Todo应用,动手把代码敲一遍。
  2. 第5至第9章可以按项目需要跳读,遇到性能、异步或测试问题再回头精读对应章节。
  3. 书中示例基于2017年的类组件与旧版依赖,练习时可用现代脚手架重建,把类组件改写为函数组件对照理解。
  4. 每章末尾的小结值得单独整理成笔记,用来串联各章之间的因果关系。

About the publisher

China Machine Press China · Founded in 1950

In addition to science and technology and professional publishing, the books in our catalog from China Machine Press also reflect a sustained focus on psychology, computing, management, finance and economics, and social sciences. In psychology, the catalog includes works by C. G. Jung and introductions to analytical psychology, as well as applied topics such as stress and health, and addiction and healing. In computing, it features Structure and Interpretation of Computer Programs (JavaScript Edition). Management and finance titles include Administrative Behavior (4th Edition), The Price of Inequality (Collector's Edition), and This Time Is Different: Eight Centuries of Financial Folly (Commemorative Edition). In the philosophy and history of science, there is The Worldview: The Third Edition. Relevant authors include C. G. Jung, William McGuire, Sonu Shamdasani, and Gabor Maté. Public information is limited; the above summarizes the publisher's profile based solely on the books in our catalog.

Contents

  1. Foreword
  2. Chapter 1 React: A New Front-End Mindset
  3. 1.1 Initializing a React Project
  4. 1.2 Adding a New React Component (1.2.1 JSX; 1.2.2 Is JSX Progress or a Step Back?)
  5. 1.3 Decomposing a React Application
  6. 1.4 How React Works (1.4.1 How jQuery Works; 1.4.2 The React Philosophy; 1.4.3 Virtual DOM; 1.4.4 Advantages of React's Approach)
  7. Chapter 2 Designing High-Quality React Components
  8. 2.1 Design Elements for Maintainable Components
  9. 2.2 React Component Data (2.2.1 prop; 2.2.2 state; 2.2.3 prop vs. state)
  10. 2.3 The Component Lifecycle (Mounting, Updating, Unmounting)
  11. 2.4 Passing Data Out of a Component
  12. 2.5 Limitations of state and prop in React Components
  13. Chapter 3 From Flux to Redux
  14. 3.1 Flux (Shortcomings of MVC Frameworks, Flux Applications, Strengths and Weaknesses)
  15. 3.2 Redux (Basic Principles, A Redux Example, Container Components and Dumb Components, Component Context, React-Redux)
  16. Chapter 4 Modular React and Redux Applications
  17. 4.1 Key Points of Modular Applications
  18. 4.2 Organizing Code Files (by Role, by Feature)
  19. 4.3 Module Interfaces
  20. 4.4 Designing the State Tree (One State Node Belongs to One Module, Avoiding Redundant Data, Keeping the Tree Flat)
  21. 4.5 A Todo Application Example (State Design, Action Creators, Combining Reducers, Views, Styles, Not Using ref)
  22. 4.6 Development Tools (Chrome Extension, redux-immutable-state-invariant, Tool Applications)
  23. Chapter 5 Performance Optimization of React Components
  24. Chapter 6 Higher-Order Components and Function-as-Child Components
  25. Chapter 7 Accessing the Server in React and Redux
  26. 7.1 Accessing APIs Through Proxies; Lifecycle and Pros and Cons of Server Access in React Components
  27. 7.2 Server Access in Redux (redux-thunk Middleware, Asynchronous Actions, Patterns and Cancellation of Asynchronous Operations)
  28. 7.3 Other Approaches to Asynchronous Operations in Redux (Choosing an Approach, Using Promise for Asynchronous Operations)
  29. Chapter 8 Unit Testing
  30. 8.1 Principles of Unit Testing
  31. 8.2 Setting Up a Unit Testing Environment (Frameworks, Code Organization, Tools)
  32. 8.3 Unit Testing Examples (Action Creators, Asynchronous Actions, Reducers, Stateless Components, Connected Components)
  33. Chapter 9 Extending Redux
  34. 9.1 Middleware (Interfaces, Usage, Promise Middleware, Development Principles)
  35. 9.2 Store Enhancer (Enhancer Interfaces, An Example Enhancer: reset)
  36. Chapter 10 Animation
  37. 10.1 Approaches to Animation (CSS3, Script-Based)
  38. 10.2 ReactCSSTransitionGroup (Todo Application Animation, Rules)
  39. 10.3 The React-Motion Animation Library (Design Principles, Todo Application Animation)
  40. Chapter 11 Multi-Page Applications

FAQ

这本书适合零基础学React吗?
不太适合。书中默认读者掌握JavaScript和ES6语法,会直接使用class、箭头函数、模块化等写法。零基础读者建议先补JavaScript与ES6,再读本书第1章。
书中的代码现在还能跑吗?
书出版于2017年,示例基于类组件、create-react-app及当时的React-Router、Redux版本,直接运行可能遇到依赖版本问题。建议用现代脚手架重建示例,把重点放在思路而非逐行复现。
只学React不学Redux,能读这本书吗?
可以分段阅读。第1、2章以及第5、6、10章基本围绕React本身展开,可以先读;第3、4、7、9章涉及Redux,需要时再补。作者也解释了为何大型应用引入Redux。
这本书和官方文档相比有什么不同?
官方文档偏重API与最新写法,本书胜在完整讲述一个应用如何从简单走向工程化:模块划分、状态树设计、性能优化、测试、同构等章节提供了官方文档不容易一次性讲清的整体视角。
这本书的评分和篇幅如何?
豆瓣评分约8.5分,全书约259至268页、12章,定价69元,ISBN为9787111565635,机械工业出版社2017年出版。

Comments

Find this book

This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.

About the author

程墨 Author

Cheng Mo: publicly available information about this author is limited, and details such as nationality, dates of birth and death, and an English name have not been clearly recorded. Judging from the two works held in the collection, Cheng Mo is an author focused on the study of the Chu Ci and classical poetry, having written Chu Ci Appreciation: Selected Readings from Jiu Ge, Tian Wen and Jiu Zhang and Classical Culture Must-Read: Chu Ci Appreciation of Li Sao. Both works fall under the categories of literature and classical poetry and center on appreciation and selected readings of Qu Yuan's works, showing the author's interest in close reading of Chu Ci texts. The writing leans toward popularizing and interpreting classical culture for readers who wish to understand the Chu Ci in greater depth, offering a useful reference in the field of traditional poetry appreciation.

More by the same author

Top rated in the same category