data • Controller: display logic • View: templates (HTML + custom attributes) • Components are coupled: when you change one, you have to change the others • So it is separation by technology (HTML, JS) • Inner micro-languages (iterators, directives) and concepts (scope)
of UI inlined in JS code • Combines templating engine with power of JS • No custom semantics • Translates to JS during development or offline with React CLI
Data passed down from parents to child by properties • Properties are immutable, but can transform to component state • Lifecycle methods (componentDidMount, componentWillMount, componentDidUpdate) • Great docs
change the state is to emit an action, an object describing what happened. <button onClick={dispatch({ type: 'COMPLETE_TODO', index: 1 })}> Complete todo </button>
specify how the state tree is transformed by actions, you write pure reducers function todos(state = [], action) { switch (action.type) { case 'COMPLETE_TODO': return state.map((todo, index) => { if (index === action.index) { return Object.assign({}, todo, { completed: true }) } return todo }) default: return state } } let store = createStore(todos)