This document discusses React, a JavaScript library for building user interfaces. It provides an overview of React concepts like components, props, state, lifecycle methods, and the virtual DOM. Components are the basic building blocks and can be composed to build complex UIs. Data flows unidirectionally from parent to child components via props, while state is local and mutable. The virtual DOM allows React to efficiently update the real DOM by comparing component trees.
18. why to use it…
• Remove logic of HTML
• No more templates
• SEO Friendly (when rendered on server)
• Component-driven development
• Reusable and interactive components
• UI componentized is the future
• It’s fast!
25. FilterableProductTable:
contains the entirety of the
example
SearchBar: receives all user
input
ProductTable: displays and
filters the data collection
based on user input
ProductCategoryRow:
displays a heading for each
category
ProductRow: displays a row
for each product
51. export default class App extends React.Component {
constructor(props) {
super(props)
this.state = {
likes: 0
}
this.like = this.like.bind(this)
}
like() {
this.setState({
likes: this.state.likes + 1
})
}
render() {
return (
<div>
<Header />
<div className="content">
<Counter likes={this.state.likes} />
<ButtonLike onClick={this.like} />
</div>
</div>
)
}
}
app.js
initial state
set the state incrementing likes
pass the state as a prop (reactive)
pass a callback to set the new state
52.
53. props state
mutable
managed only in own
component (private)
re-render on each change
immutable
pass to child within render
pass parent callbacks
64. WhatisDOM?
• Document Object Model
• It defines the logical structure of documents and the way a
document is accessed and manipulated.
• DOM API is almost cross-platform and cross-browser
• Inspect tool
66. VirtualDOM
• Inspired by the inner workings of React by facebook
• Representation of the DOM using javascript in-memory
• Algorithm to identify changes
• Computes minimal DOM mutations
• Create a queue with all mutations
• Executes all updates without recreating all of the DOM nodes
86. Where I can study react?
Official React Docs
https://facebook.github.io/react/docs/getting-started.html
News
https://twitter.com/reactjs
Airbnb React/JSX Style Guide
https://github.com/airbnb/javascript/tree/master/react
https://twitter.com/ReactJS_News