React Fundamentals Flashcards
Why React?
Just JavaScript Unidirectional Dataflow Composition Explicit Mutations Declarative
composition
composition of components
component examples
, …
component definition
functionality wrapped into isolated container, the component;
component ~ function; ie
components manage their own state; clear boundaries for managing complexity in applications
large app built from?
small apps; components
imperative vs declarative
imperative: tell the computer how to do something
declarative: tell the computer what to do
declarative vs functional
functional: doesn’t alter state
declarative: description of what, typically doesn’t alter state
react: mostly declarative
declarative handling of requests for a component; yet state is stored somewhere, and is set + altered.
Unidirectional Data Flow
Manage state in your application. UI is going to update to that state.
UI is a
a function of state.
Explicit mutations
explicitly change state with setState
React pieces we’re to learn
Babel React Router Axios Webpack React
React Router
maps specific url to specific component
Webpack
“code bundler”; uses Bable
Bable
“code transformer”
Axios
HTTP Requests
declarative, analogy
directions; declarative: give address. imperative: step by step.
delegation of imperative specificity (imperative abstraction)
code bundler
takes code, transforms and bundles it; from one version to another (compliant)
webpack needs to know:
- starting point of your application, or your root JavaScript file
- which transformations to make on your code.
- to which location it should save the new transformed code.
npm commands
npm init
npm install --save
npm run test
add test command, e.g. ava
“scripts”: {
“test”: “ava ‘app/**/*.test.js’ –verbose –require ./other/setup-ava-tests.js”
}