Reactions
Learned some React today and figured I’d share my notes:
- JSX must return a single element, AKA a node, because otherwise
ReactDOM.render()
will throw a tantrum - All elements in JSX must be closed, including
<hr>
and<br>
, because JSX is pretending to be HTML - Function names must start with a capital letter—it appears functions are actually classes in a trench coat
- React components have to be passed to the
ReactDOM.render()
method using markup syntax:ReactDOM.render(<Component />, targetNode)
. This is because– actually I have no fuckin clue, this is wack - When passing an integer as a prop, you need to wrap it in curly braces, because they gave up halfway through making it look like HTML attributes
- JavaScript in JSX needs to be surrounded with curly braces because raw JavaScript is flammable and must be insulated