Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Actions may not have an undefined "type" property

I am using react native and redux, this is my action:

import EMPLOYEE_UPDATE from './types';

export const employeeUpdate = ({ prop, value }) => {
  return (
    {
      type: EMPLOYEE_UPDATE,
      paylaod: { prop, value }
    }
  );
};

but i get this error:

Actions may not have an undefined "type" property. Have you misspelled a constant?

EDIT: the types.js file is:

export const LOGIN_USER_FAILED = 'loing_user_failed';
export const SHOW_SPINNER = 'show_spinner';
export const EMPLOYEE_UPDATE = 'employee_update';
like image 604
farmcommand2 Avatar asked Aug 26 '17 05:08

farmcommand2


2 Answers

You need to import EMPLOYEE_UPDATE from types file like this

import { EMPLOYEE_UPDATE } from './types';
like image 180
Prakash Sharma Avatar answered Oct 09 '22 23:10

Prakash Sharma


You need to import the const as a named import rather than a default import since you have exported it as a named const.

 import {EMPLOYEE_UPDATE} from './types';

See this answer for details on named and default exports:

in reactjs, when should I add brackets when import

like image 42
Shubham Khatri Avatar answered Oct 09 '22 23:10

Shubham Khatri