concept loading indicator in category react
appears as: loading indicator

This is an excerpt from Manning's book Redux in Action.
FETCH_TASKS_STARTED—Dispatched when a request is initiated. Typically used to render a loading indicator (which you’ll do in this section).
Update the TasksPage component to render a loading indicator when the fetch is in progress.
Listing 4.15. src/actions/index.js
function fetchTasksStarted() { return { type: 'FETCH_TASKS_STARTED', }; } export function fetchTasks() { return dispatch => { dispatch(fetchTasksStarted()); #1 api.fetchTasks().then(resp => { setTimeout(() => { #2 dispatch(fetchTasksSucceeded(resp.data)); #2 }, 2000); #2 }); }; } #1 Dispatches the fetchTasksStarted action creator to signify a request is in progress #2 setTimeout ensures the loading indicator will stay on the page for more than a fraction of a second. !@%STYLE%@! {"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":8,\"ch\":54},{\"line\":8,\"ch\":56}],[{\"line\":18,\"ch\":0},{\"line\":18,\"ch\":2}],[{\"line\":11,\"ch\":54},{\"line\":11,\"ch\":56}],[{\"line\":12,\"ch\":54},{\"line\":12,\"ch\":56}],[{\"line\":13,\"ch\":54},{\"line\":13,\"ch\":56}],[{\"line\":19,\"ch\":0},{\"line\":19,\"ch\":2}],[{\"line\":11,\"ch\":54},{\"line\":11,\"ch\":56}],[{\"line\":12,\"ch\":54},{\"line\":12,\"ch\":56}],[{\"line\":13,\"ch\":54},{\"line\":13,\"ch\":56}],[{\"line\":19,\"ch\":0},{\"line\":19,\"ch\":2}],[{\"line\":11,\"ch\":54},{\"line\":11,\"ch\":56}],[{\"line\":12,\"ch\":54},{\"line\":12,\"ch\":56}],[{\"line\":13,\"ch\":54},{\"line\":13,\"ch\":56}],[{\"line\":19,\"ch\":0},{\"line\":19,\"ch\":2}]]"} !@%STYLE%@!