0

How to convert this arrow function to normal function expression to help me understand it better?

export const updateDetails = data => dispatch => dispatch({
  type: ActionTypes.USER_UPDATE_DETAILS_REQUEST,
  data
});

i understand that the data is one of the function parameters but I don't understand what is the purpose of this part: "dispatch =>". Is it a parameter? of what exactly?

Omtechguy
  • 3,321
  • 7
  • 37
  • 71
  • 1
    It's a curried function - the first one takes `data` and returns a second function that takes `dispatch`. The second function then runs `dispatch()` and uses `data` in the invocation. – VLAZ Dec 11 '19 at 15:56
  • The second argument of the arrow function is the return value of the function. In this case, you are returning another arrow function. So the "normal function expression" will be: `function updateDetails(data) { return function (dispatch) { return dispatch({ type: ActionTypes.USER_UPDATE_DETAILS_REQUEST,, data, }); }; }` (https://pastebin.com/GDhx474G) – jtwalters Dec 11 '19 at 16:08

0 Answers0