Skip to Content
React学习手册
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学习手册
287
12
React
服务器端应用
目前为止,我们已经使用
React
构建了一些完全可以在浏览器中运行的小型应用程
序。它们在浏览器中收集数据,并使用浏览器的
storage
存储数据。这是合情合理的,
因为
React
是一个视图层。采用它的主要目的是渲染
UI
。不过,大部分应用程序至少
都存在某种后端,并且我们需要理解如何将应用程序和服务器端整合到一起。
即使用户的客户端应用程序完全依赖于使用云服务作为后端,仍然需要从这些服务中
读取或者发送数据。在
Flux
的影响范围内,有特定的位置处理这些传输,并且还有不
少类库可以帮助用户处理和
HTTP
请求有关的延迟问题。
此外,
React
还支持同构渲染,这意味着它能够兼容浏览器之外的其他平台。同时也
说明我们在页面内容抵达浏览器之前,在服务器端可以对
UI
进行渲染。利用服务器端
渲染,我们可以提高应用程序的性能、可移植性和安全性。
从本章开始,我们将会学习同构性和通用性之间的区别,以及这两个概念和
React
间的关系。接下来,将会介绍如何使用通用的
JavaScript
构建一个同构的应用程序。
最后,我们会通过添加一个服务器并首先在服务器端渲染
UI
来改进颜色管理器程序。
同构性和通用性
同构性和通用性这两个术语通常用于描述在客户端和服务器端均可使用的应用程序。
虽然这两个术语在描述相同应用程序时可以互换,但是它们之间存在细微的差别。同
288
12
构性应用程序是可以在多个平台上渲染的程序。通用性代码意味着完全相同的代码可
以在多种环境下运行。
1
Node.js
允许用户复用相同的代码,比如在浏览器中执行的代码、其他诸如服务器、命 ...
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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

React快速上手开发

React快速上手开发

Stoyan Stefanov
C++语言导学(原书第2版)

C++语言导学(原书第2版)

本贾尼 斯特劳斯特鲁普

Publisher Resources

ISBN: 9787519814236