Skip to Content
React 16 Tooling
book

React 16 Tooling

by Adam Boduch, Christopher Pitt
April 2018
Intermediate to advanced content levelIntermediate to advanced
298 pages
6h 34m
English
Packt Publishing
Content preview from React 16 Tooling

The API abstraction

For this application, I'm using a simple API abstraction. In Redux apps, you should be able to have your asynchronous functionality—API or otherwise—encapsulated in its own module or package. Here's what the api.js module looks like, with some of the mock data redacted for brevity:

const LATENCY = 1000; const BOOKS = [ { title: 'React 16 Essentials', author: 'Artemij Fedosejev', imgURL: 'big long url...' }, ... ]; export const fetchBooks = () => new Promise(resolve => { setTimeout(() => { resolve(BOOKS); }, LATENCY); }); export const createBook = (title, author, imgURL) => new Promise(resolve => { setTimeout(() => { BOOKS.push({ title, author, imgURL }); resolve(); }, LATENCY); }); export const fetchBook = title => new ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Pro React 16

Pro React 16

Adam Freeman

Publisher Resources

ISBN: 9781788835015Supplemental Content