Skip to Content
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
Explore Skills
Cloud Computing
Microsoft Azure
Amazon Web Services (AWS)
Google Cloud
Cloud Migration
Cloud Deployment
Cloud Platforms
Data Engineering
Data Warehouse
SQL
Apache Spark
Microsoft SQL Server
MySQL
Kafka
Data Lake
Streaming & Messaging
NoSQL Databases
Relational Databases
Data Science
Pandas
R
MATLAB
SAS
D3
Power BI
Tableau
Statistics
Exploratory Data Analysis
Data Visualization
AI & ML
Generative AI
Machine Learning
Artificial Intelligence (AI)
Deep Learning
Reinforcement Learning
Natural Language Processing
TensorFlow
Scikit-Learn
Hyperparameter Tuning
MLOps
Programming Languages
Java
JavaScript
Spring
Python
Go
C#
C++
C
Swift
Rust
Functional Programming
Software Architecture
Object-Oriented
Distributed Systems
Domain-Driven Design
Architectural Patterns
IT/Ops
Kubernetes
Docker
GitHub
Terraform
Continuous Delivery
Continuous Integration
Database Administration
Computer Networking
Operating Systems
IT Certifications
Security
Network Security
Application Security
Incident Response
Zero Trust Model
Disaster Recovery
Penetration Testing / Ethical Hacking
Governance
Malware
Security Architecture
Security Engineering
Security Certifications
Design
Web Design
Graphic Design
Interaction Design
Film & Video
User Experience (UX)
Design Process
Design Tools
Business
Agile
Project Management
Product Management
Marketing
Human Resources
Finance
Team Management
Business Strategy
Digital Transformation
Organizational Leadership
Soft Skills
Professional Communication
Emotional Intelligence
Presentation Skills
Innovation
Critical Thinking
Public Speaking
Collaboration
Personal Productivity
Confidence / Motivation
Features
All features
Verifiable skills
AI Academy
Courses
Certifications
Interactive learning
Live events
Superstreams
Answers
Insights reporting
Radar Blog
Buy Courses
Plans
Sign In
Try Now
O'Reilly Platform
book
React学习手册
by
Alex Banks
,
Eve Porcello
December 2017
Intermediate to advanced
329 pages
6h 9m
Chinese
China Electric Power Press Ltd.
Content preview from
React学习手册
Redux
|
181
State
将
State
存放于一处统一管理的想法并不疯狂。事实上,我们在上一章中就是这么做
的。我们将它存放于应用程序的根组件上。在纯
React
或者
Flux
应用中,比较推荐的做
法是将
State
尽量存放在少数几个对象中。在
Redux
中,这是一条规则。
注
2
当你听到必须将
State
存放在一个地方时,可能会觉得那是个不合理的需求,特别是
当你需要管理多种数据时。接下来看看如何在一个包含多种数据的应用程序中实现
这个目标。我们将会考察一个社交媒体应用程序,其
State
分布于不同组件中(见图
8-1
)。该应用程序本身包含用户的
State
。所有的短信都存储在上述
State
之中。每条
短信包含自己的
State
,所有帖子都存放在
posts
组件中。
图
8
-
1
:组件包含自己的
State
的
React
应用程序
注
2
:
Redux Docs,
“
Three Principles
”
(http://bit.ly/2mJ0U4Y)
。
182
|
第
8
章
类似上述结构的应用程序可能会运行良好,不过随着程序规模的增长,管理应用程序
的整体
State
可能会变得愈加困难。考虑到每个组件都将使用其内部的
setState
方法来
改变自身的
State
,可能了解更新命令源也会变得很麻烦。
哪些短信被转发了?哪些帖子被阅读了?为了了解这些细节,我们必须深入组件树, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial
You might also like
React快速上手开发
Stoyan Stefanov
流畅的Python
Luciano Ramalho
C++语言导学(原书第2版)
本贾尼 斯特劳斯特鲁普
C++程序设计:原理与实践(基础篇)(原书第2版)
本贾尼 斯特劳斯特鲁普
Publisher Resources
ISBN: 9787519814236