osama laden
osama laden

Reputation: 71

an unexpected error in redux while writing actions

Here is the code which shouldn't throw any error as per the syntax of redux but it gives an error at line where payload is located.It is

Error: 'Unexpected token, expected ;'
// code part 
    const xyz =(response)=>{
      return
      {
        type:GET_ALL_ABC,
        payload:{
          response,
        }
      };
    }

Upvotes: 0

Views: 34

Answers (1)

Ravi Theja
Ravi Theja

Reputation: 3401

Your code should be

const xyz =(response)=>{
    return ({
      type:GET_ALL_ABC,
      payload:{
        response,
      }
    });
}

with your code the function after compiling will be

const xyz = response => {
  return;
  {
      type:GET_ALL_ABC,
      payload:{
        response,
      }
    };
  }
} 

Upvotes: 1

Related Questions