Interfaces folder - gabrielrangel95/react-native-folder-structure GitHub Wiki

The interfaces folder contains all interfaces that will be used on the app. Mainly, it is used for redux actions and reducers. In that way, if we import it in a component connected to redux, we will have the props for this component

Ex: <user.ts>

import { IGenericErrorAction } from '@interfaces/action';
import { Action } from 'redux';

export interface IUserLoginInterface {
  email: string;
  password?: string;
}

export interface IUserInterface {
  email: string;
  name: string;
  id: string;
}


export interface IStateToProps { // my reducer
  userData: IUserInterface | undefined;
  loading: boolean;
  errorOnLogin: string | undefined;
  loginSuccess: boolean | undefined;
}

export interface IDispatchToProps {
  tryLoginRequest(user: IUserLoginInterface): ITryLoginRequest;
  tryLoginSuccess(user: IUserInterface): ITryLoginSuccess;
  tryLoginFailure(message: string | undefined): IGenericErrorAction;
  logoutUser(): Action;
}


export interface ITryLoginRequest extends Action {
  type: string | undefined;
  payload: {
    user: IUserLoginInterface
  };
}

export interface ITryLoginSuccess extends Action {
  type: string | undefined;
  payload: {
    user: IUserInterface,
    token: IToken
  };
}

Ex: <action.ts>

import { Action } from 'redux';

export interface IGenericErrorAction extends Action {
  type: string | undefined,
  payload: {
    message: string | undefined;
  }
}

⚠️ **GitHub.com Fallback** ⚠️