7

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';
farmcommand2
  • 1,418
  • 1
  • 13
  • 18

2 Answers2

8

You need to import EMPLOYEE_UPDATE from types file like this

import { EMPLOYEE_UPDATE } from './types';
Prakash Sharma
  • 15,542
  • 6
  • 30
  • 37
  • 1
    @farmcommand2 Redux does not have any idea wheather you are importing it correctly or not. All it knows is that `type` is undefined and thats what it show in error. I think this is the best error redux can give to you. – Prakash Sharma Aug 26 '17 at 06:43
1

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

Shubham Khatri
  • 270,417
  • 55
  • 406
  • 400