React for Real Front-End Code, Untangled. L. Fischer

Категория: JavaScript

 Many web applications allow users to browse and edit content without reloading the page—for example, editing a document, selecting people to email from a contact list, or even browsing a list of events and buying a ticket. While web pages used to be just about the display of information, now a fair amount of business logic might run in the browser. To handle this logic, you often create specialized code—the data model for your application. In all these applications, you must update the user interface and data model consistently. Since every web page is a tree of elements, called the DOM, you could apply a change directly to the DOM on every action, but this makes it difficult to distinguish business logic from visual adjustments. When you make visual adjustments, you manipulate DOM elements to change the appearance of the user interface. That’s why web developers have started to prefer to store the data in a separate data structure, like a JavaScript object. But now you have a new problem: you need to communicate the changes from the data structure to the DOM and back. You could add DOM elements with native browser functions such as appendChild and change element contents by overwriting the innerHTML attribute on DOM nodes. This forces you to spend time on boilerplate code, away from your application’s core logic. Since this boilerplate turns out similarly across different web applications, it makes sense to offload DOM manipulation to a library. React is a JavaScript library that automatically updates the DOM when the data changes. It makes writing highly interactive web pages faster and more reliable. It’s easy to use and integrates with a wealth of techniques and other libraries In this book, you’ll learn the fundamentals of building user interfaces with React and how to prepare an application for production so that it loads efficiently. You’ll also test components, use React with the Redux library for more complex applications, and work with other libraries. You’ll get hands-on practice as you work through complete examples.


    Ничего не найдено.