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) {


  } else {




TILApril 22, 2019by Dmitry Sokolov

Integrate Drawer inside Stack Navigation in React Native

I wanted to use more than one navigation in a React Native app.

The documentation didn’t give a clear way to implement this.

Here is what you can do on purpose to add several types of navigation in your React Native app:

import { createStackNavigator, createDrawerNavigator } from 'react-navigation';

import * as Screens from './screens/index';

import Drawer from './components/DrawerMenu';

import getDrawerWidth from './utils/scale';

const AppStackNavigator = createStackNavigator({

  home: {

    screen: Screens.MainScreen,


  about: {

    screen: Screens.AboutScreen,



const AppNavigator = createDrawerNavigator(


    home: {

       screen: AppStackNavigator,




    contentComponent: Drawer,

    drawerWidth: getDrawerWidth,

    headerMode: 'none',



export default AppNavigator;