- updated slides http://btholt.github.io/complete-intro-to-react/all.html
- updated repo https://github.com/btholt/complete-intro-to-react/tree/start
- It is possible to learn the entire surface area of React.
- This class will teach you React + tools: webpack, babel, etc.
- Tools introduce complexity but help get around pain-points, more complex, but easier to work on
- node >= v4.; nvm
npm install --save react
==>yarn add react
package.json
stays, butnpm-shrinkwrap.json
==>yarn.lock
- yarn is deterministic, whereas npm isn't (which sucks, and I've ran against this dozens of times)
- no more
rm -rf node_modules/
thennpm install
- essentially bad at libs, good for apps
- Yehuda Katz who did Cargo for rust was involved (at some level, arch?)
- yarn installs all deps in a flat structure and symlinks them together
yarn upgrade-interactive
exists
(He mentioned preact).
(He skipped global installs needed for this course).
- no es6, no .jsx needed to roll with React
- React is solving the problem: it's a view library (with very minimal state).
- MVC pattern doesn't really work in the front-end
- request/response cycle
- instead of separation of concerns, have separation of components
- React + jQuery can be done, but shouldn't be done
- mentioned http://emmet.io/
- react / react-dom
- createClass creates a class
- createElement creates an instance ("stamp")
- we're not using jsx yet
- install the Babel syntax highlighting for Atom
- every component needs a
render()
- should be a pure function that returns markup - element helpers are variadic - can handle arrays or n args
- annoying ; debate
.createFactory()
- makes a factory method for whatever components you have, essentially wrapping your component, abstracting away the need forcreateElement
(not normally used with jsx)- props - read only props that are simply received from parents, by def not writable
- props can handle anything that JS can pass
- a whole minute of talking about CSS named colors...
style
prop to attribute making
- no
gofmt
is cool, butstandard
isn't that- standard is just eslint with it's own bike-shedded preferences
- eslint pragmas are a thing
- package.json .scripts list of commands to run
npm run lint
=> { "scripts": { "lint" : "standard" } }- grunt / gulp !== npm scripts
- webpack is a code bundler with loaders that is optimized for delivering code to the front-end
import React from 'react';
export default Foo;
import
vs.require
live-code / tree shaking- npm install -g [email protected] (as of these notes, we're at 2.2.1)
- webpack understands
NODE_ENV
- code splitting is possible w/ webpack