Let's talk about
Let's talk about
getState()
dispatch(action)
subscribe(listener)
replaceReducer(nextReducer)
Let's talk about
(state, action) => newState
state
↓
action
↓
array.reduce(
function(accumulator, currentValue, currentIndex, self),
initialValue
)function* changes() {
/* yield user interactions and other effects */
}
changes().reduce(
function(state, action) { /* compute the next state */ },
initialState
)let reducer = (state, action) => state + action;
let arr = [4, 8, 15, 16, 23, 42];
// plain js
let sum = arr.reduce(reducer);
// Redux
let store = createStore(reducer);
arr.forEach(store.dispatch);
let sum = store.getState();Let's talk about
Lifecycle Methods
HOCs
Hooks
prop drilling chains
state everywhere
fat components
getderivedstatefromprops
shouldcomponentupdate
many renders
withState
withEffect
withPain
withMemo
console.log debugging
combineReducers
createStore
<Provider store={store}><App /></Provider>
mapStateToProps
mapDispatchToProps
connect
Let's talk about
function* fetchUser(action) {
try {
const user = yield call(Api.fetchUser, action.payload.userId);
yield put({type: "USER_FETCH_SUCCEEDED", user: user});
} catch (e) {
yield put({type: "USER_FETCH_FAILED", message: e.message});
}
}
function* mySaga() {
yield takeLatest("USER_FETCH_REQUESTED", fetchUser);
}Let's talk about