Skip to main content

Posts

Showing posts with the label usereducer with side effects

Use Reducer With Side Effects

https://www.npmjs.com/package/use-reducer-with-side-effects https://github.com/conorhastings/use-reducer-with-side-effects/blob/master/src/index.js import  useReducerWithSideEffects ,   {  UpdateWithSideEffect ,  Update  }   from   ' use-reducer-with-side-effects ' ;   function   Avatar ( {  userName  } )   {    const   [ {   fetchingAvatar ,   avatar   } ,   dispatch ]   =   useReducerWithSideEffects (      ( state ,  action )   =>   {        switch   ( action . type )   {          case   FETCH_AVATAR :   {            return   UpdateWithSideEffect ( {   ... state ,  fetchingAvatar :   true   } ,   ( state ,  dispatch )   =>   {   //  the second...