concept react in category isomorphic web applications

This is an excerpt from Manning's book Isomorphic Web Applications: Universal Development with React.
React is one of the pieces that makes building an isomorphic web app possible. React is a library, open sourced by Facebook, for creating user interfaces (the view layer in your app). React makes it easy to express your views via HTML and JavaScript. It provides a simple API that’s easy to get up and running but that’s designed to be composable in order to facilitate building user interfaces quickly and efficiently. Like many other view libraries and implementations, React provides a template language (JSX) and hooks into commonly used parts of the DOM and JavaScript.
React also takes advantage of functional concepts by adhering to single-direction data flows from the top-level component down to its children. What makes it appealing for isomorphic apps is how it uses a virtual DOM to manage changes and updates to the application.
React isn’t a framework like Angular or Ember. It only provides the code you use to write your view components. It can fit easily into a Model-View-Controller (MVC) style architecture as the view. But there’s a recommended way to build complex React apps, which is covered throughout the book.
React is a library for creating user interfaces, invented and used by Facebook. The React ecosystem has expanded rapidly over the last few years. It’s now possible to use React in many types of applications and architectures. This chapter will teach you what you need to know about React to build an isomorphic application. I’ll start by teaching you some React basics. The next chapter covers React component patterns and introduces React Router.
So far, we’ve discussed components written as pure functions and stateless class-based components. React can also handle state inside components. Sometimes this might be application state. More often, this state ends up being user-interaction state. For example, is a modal hidden or displayed?
Listing 3.12. Todo component—components/todo/todo.jsx
import React from 'react'; import List from './list.jsx'; import Tabs from './tabs.jsx'; import AddItem from './addItem.jsx'; class Todo extends React.Component { constructor(props) { super(props); this.state = { tab: 0 } } updateTabView(index) { this.setState({ tab: index }) } filterTodos() { #1 return this.props.todos.filter((todo) => { if (this.props.activeTab == 0) { return true; } else if (this.props.activeTab == 1) { return !todo.done; } else { return todo.done; } }); } render(){ let actions = {updateTabView: updateTabView} #2 return ( <div className='todo-app'> <h1>ToDo App</h1> <Tabs {...this.props} actions={actions}/> #3 <List {...this.props} data={this.filterTodos()} /> #4 <AddItem {...this.props} /> </div> ) } } export default Todo; #1 Method provides current list of todos to show based on the activeTab property. #2 Set updateTabView method as an action. #3 Pass in actions to the Tabs component so each tab can call back to this root component to update the state. #4 Pass in the calculated list of todos to List component. !@%STYLE%@! {"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":20,\"ch\":63},{\"line\":20,\"ch\":65}],[{\"line\":47,\"ch\":0},{\"line\":47,\"ch\":2}],[{\"line\":33,\"ch\":63},{\"line\":33,\"ch\":65}],[{\"line\":48,\"ch\":0},{\"line\":48,\"ch\":2}],[{\"line\":37,\"ch\":63},{\"line\":37,\"ch\":65}],[{\"line\":49,\"ch\":0},{\"line\":49,\"ch\":2}],[{\"line\":38,\"ch\":63},{\"line\":38,\"ch\":65}],[{\"line\":50,\"ch\":0},{\"line\":50,\"ch\":2}]]"} !@%STYLE%@!