Design simple views for each state in your application, and React will efficiently update and render just the right components when your data changes. Declarative views make your code more predictable and easier to debug.”
compose them to make complex UIs. Since component logic is written in JavaScript instead of templates, you can easily pass rich data through your app and keep state out of the DOM.” Components
state later) • Handles it’s state and passes it down as props to presentational components // Component const NameOutput = ({ enteredName }) => <h1>Hi! My name is {enteredName}</h1> // Container class EnterName extends Component { render() { return <div> <input onChange={(ev) => this.setState({ name: ev.target.value })} /> <NameOutput enteredName={this.state.name} </div> } }
Can be passed on down ◦ Prefer specific or no passing down ◦ Only pass on all props when necessary • Are a reflection of your component tree ◦ You only get relevant data ◦ And only pass on the data relevant for your children
or needs to store data you put them into its State • Immutable, plain Objects • Pass on down as props • Eventually Props can be the source (do not assign by reference!) this.state = this.props.whatever this.state = { ...this.props.whatever }
a copy of the actual DOM in memory • On Change (Props or State) ◦ It diffs the DOMs in memory (fast!) ◦ Parses tree and only rerenders elements where necessary in memory (faster!) ◦ Mutates DOM all at once (even faster!) Only one DOM mutation instead of multiple, each may requiring a browser repaint ◦ Reconciliation
` <div id=”mount”> ${render(<MyComponent />)} </div> `; If you call the code from 2 slides before on client-side now, React will recognize the server-side rendered component and only attach the missing parts powered by VDOM (very, very, very performant!)
Official React announcement • Learning Functional Programming with JavaScript by Anjana Vakil Very basic but great introduction to Functional Programming • Functional Programming Series by Eric Elliott Great for diving deeper into Functional Programming • How we built Twitter Lite Great example for a light, mobile-first, progressive web app, built with React
POST / - Create task GET /:id - Get specific task PUT /:id - Update specific task DELETE /:id - Delete specific task Schema: TodoItem { “title”: “Task title”, “completed”: false, “created_at”: “1498566756549”, “updated_at”: “1498566794201” } Run your own: https://github.com/ronnyhaase/nodod