What do parenthesis surrounding brackets in the return statement of an ES6 arrow function do?

前端 未结 4 857
生来不讨喜
生来不讨喜 2021-01-25 07:29

For example in redux actions, I\'ve seen in someone\'s code:

export const updateMessage = text => {
   return (dispatch) => {
     dispatch(updateChatMess         


        
4条回答
  •  半阙折子戏
    2021-01-25 08:25

    If you wrap the brackets with parenthesis you are making your function return an object literal (thus you don't need the return keyword). If you don't use parenthesis you have to use the return keyword.

提交回复
热议问题