May 2019
Intermediate to advanced
496 pages
10h 38m
English
There are two new types of function: sagas and reducers. They work in tandem with each other. The approach we'll use in this section is to build a single Redux action that works its way through both a saga and a reducer. We will "scaffold" barebones implementation for both, for that single action, before fleshing out the functions with more detail.
For reference, here's the existing code that we'll be extracting from CustomerForm. It's all helpfully in one function, doSave, even though it is quite long:
const doSave = async () => { setSubmitting(true); const result = await window.fetch('/customers', { method: 'POST', credentials: 'same-origin', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(customer) ...Read now
Unlock full access