README
React
Given design:
1) Break UI into component hierarchy
2) Build Static version in react(no state, state for interactivity)
3) Identify The Minimal (but complete) Representation Of UI State(calculate computed terms on render and remember if its passed in as props then its the parent's job to change it)
4) Identify where state should live
5) Add Inverse Data Flow, pass update fts to lower components
Data Flow
Data flows down from parent to child, so if multiple components have a shared state put it in the closest common ancestor
Notice if we rerender a parent component with setState() all the children get rerendered (if needed?)
If something can be derived from either props or state, it probably shouldn’t be in the state.
Thinking about React
Data flows down from parent to child
Try to get small, reusable components
Components take props and return react component
Passing props for specialization is equivalent of composition/inheritance (i.e create WelcomeDialog by passing in specific props to Dialog)
can even pass other components in props and choose what to do with it
Need multiple children??
Components
Cant change props
Using Components
If you have user defined component(capitalized) in JSX, passes in props
Passing in props to children
Example
Lets say we are trying to make a F & C temp indicator
Temperature Input for F or C
Temp Calculator
Last updated