#react talk for brooklynjs
##what is react
React.createClass
this class (say, Hero
) will return
some html -- very DOM-like. then when this component is rendered, React uses its virtual DOM (is it stores virtual DOM) to figure out where it needs to insert this new html in order to make the virtual DOM === real DOMprops
-- which are like pieces of data. these props are passed down from one component to the next, the goal being a) it's easier to follow the data flow b) keeps things modular c) fast
-> versus two-way data binding
-> example##the "react way"
##how does it work
this.props
) and return what to display (render
)this.state
) -- when a component's state data changes, react component gets re-rendered###what's this jsx thing
/** @jsx React.DOM */
at the beginning of your file -- you're saying 'hey JSX, i want you to process this file for React. tx <3 u'render
function at the end of React##why should i use it
##what is react NOT?
##okay, give me an example
##things to look out for / tricky things
return
function just returns one dom element. so you can't return two divs -- just oneonChange
are often passed around b/t components -- be careful not unconsciously to override one. you can avoid this by having a local handleChange
that then calls this.props.onChange
(so you actually call both)