reactjs - 什么是 "universal app"?

标签 reactjs redux

我一直在阅读有关 React 和 Redux 的内容,他们提到了“通用应用程序”。例如:

"You’ll probably want a (de)serialization mechanism for writing universal apps and hydrating their state from the server..." (From http://rackt.org/redux/docs/introduction/PriorArt.html)

什么是通用应用程序?

最佳答案

在此上下文中,通用应用程序是指能够根据情况在服务器或客户端中呈现的 Web 应用程序。

有时也可以称为“同构应用程序”。

更完整的解释来自https://www.npmjs.com/package/webpack-isomorphic-tools :

What is a web application? I would define it as a box with a bunch of inputs (keyboard events, mouse events) and a display as an output. A user walks into your website and your web application renders a "page" on his display.

At first all the rendering used to happen on the server. But then "AJAX" came (in 2005) and it opened a possibility of moving all rendering logic to the client (user's web browser) leaving the server with just serving API calls (data fetching, data modification, etc).

And so numerous javascript frameworks emerged to serve the purpose of client side rendering and routing. But then everybody realised that this new way of building web applications broke search engine indexing because the search engines didn't talk any javascript.

Then the age of super-responsive websites came and also the iPhone emerged and the battle for milliseconds began. And everybody noticed that client side rendering introduced unnecessary data fetching roundtrips on the first page load: the web browser loaded markup templates and scripts first and then asked the server for the actual data to display.

So it became obvious that web applications need to be "isomorphic" ("universal"), i.e. be able to render both on the client and the server, depending on circumstances. It was quite manageable: one just had to write the rendering logic in such a programming language that is able to run both on client and server. One such language is javascript.

关于reactjs - 什么是 "universal app"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33610399/

相关文章:

javascript - Redux mapStatmentToProps 返回未定义

unit-testing - Redux 如何在单元测试中更新存储?

javascript - 单独分配对象不会触发 React 中的状态更改

javascript - 如何在 ReactJS 中使用事件(onLoad 或其他)从 API 加载随机引用?

javascript - Redux saga 事件 channel 在执行另一个 saga 后终止

javascript - 如何从键盘编辑时间选择器的值?

javascript - 如何让 React 与 Grunt 和 Babel 一起工作?

ios - 在 native iOS 应用程序中使用类似 Redux 的模式是一种好习惯吗?

javascript - 如何访问 React props 中的嵌套对象属性

javascript - 当reactjs中的变量更新时,以及如何强制更新