DEV Community

async actions in redux

hemanth.hm on September 03, 2018

The most common question I hear post intro to redux is: "How do I fetch some data in actions?" Most of them would hit the roadblock with: Actions ...
Collapse
 
chgldev profile image
Chris

Great and easy to grasp examples!
In your reducer example, did you mean to write this for the FETCHING_COMIC case?:

case 'FETCHING_COMIC':
  return {
    ...state,
    loading: true
  }
Collapse
 
hemanth profile image
hemanth.hm

Yeah, rather:

 case 'FETCHING_COMIC':
      return {
        ...state,
        fetching: true,
        comic: action.comic
      }
const initialState = {
  fetching: false,
  error: false,
  comic: null
}

What say?