kanban that people use
import X from m
andimport {X,Y,Z} from m
export default var X
andexport var X
https://babeljs.io/repl https://facebook.github.io/react/docs https://facebook.github.io/react/docs/jsx-in-depth.html
- components are just state machines
- components have state, props and render html
- components are uppercase, html is lowercase
- state, setState, getInitialState called once
- getInitialState is called once for each mount
- props, JSX attrs, never write to
this.props
- props has children, which are html elements
- return (jsx), single root
- {} surrounds javascript
- ... spread operator, e.g.,
{...props}
- write unicode, \u0000 string,
- DOM events
- xml attr names: className, htmlFor
- js function bind(), handy for component funcs
- SRP
- static page (typing intensive)
- interactivity (thinking intensive)
- DRY - minimal, complete state representation
- how to answer "is it state?"
- passed via props from owner, no.
- changes over time, no.
- computable from state/props, no.
- original data, no. (props from owner)
- filtered data, no. (computable)
- input box text, yes. (changes/time)
- checkboxes, yes. (changes/time)
- which component owns the state
- identify components that render state
- find common owner component
- create component above if none exists
- add getInitialState for the component
- pass prop=state to owned components
- ownee components use props
- inverse data flow
- owner passes a callback as prop
- ownee calls callback on DOM events
- owner state is mutated in the callback
- child reconciliation: DOM updates, render pass
- reconciliation is first come first serve
- reconciliation is problematic with
- stateful children
- hide children instead of destroy
- dynamic children (as in search results)
- reconciles keyed children
- reordered not clobbered
- destroyed not reused
- from owner, add props
key
to ownee - do not add
key
on child container
- performance problems? shouldComponentUpdate
- DOM manipulation is way slower than JS
- validation only in development mode
- React.PropTypes
- default props getDefaultProps
- component mixins for cross-cutting concerns
- deconstruction
var { a, ...more } = object
- forms
- textarea not children, use value attr
- onChange or readOnly
- select uses value, not option's selected
- the event system is synthetic
- only IE 9 and above (lol)
3 principles
- all app state lives in a single store
- state is read-only
- use reducers and actions to modify
- actions express an intent to mutate
- changes are made with are pure functions
- must return new state object
- reducers can manage subtree of state
- function reducer(state=default, action)
- use actions to pass any additional data
other redux lessons
- difference between action and action-creator
- reducer composition and store creation
- only one store (use reducer composition)
- when do I call render?
- is getInitialState really called once?
- what is ReactLink?
- what is development mode?
- valid use case for component.forceUpdate?
- what is this ref prop stuff