#redux

TILJuly 17, 2019by Maxim Romanov

How to handle 401 unauthorized error in a Redux React application

In response to a client request, the server may return a 401 Unauthorized error. You must correctly catch it, for example, clear the state and redirect to the authorization page. To solve this problem, we wrote a custom Middleware which, in our opinion, is the best solution.


import * as actions from 'actions';



const authInterceptor = ({ dispatch }) => (next) => (action) => {

  if (action.status === 401) {

    dispatch(actions.removeJwt());

  } else {

    next(action);

  }

};

LongreadsJanuary 15, 2019by Andrey Suhomozgy

Creating Sortable List with React, Redux, and Reselect

Will write simple React application with only one table and make it be sortable. But will keep sortable params inside Redux state and will use reselect lib to sort the collection.
Read more