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

前端 未结 4 808
生来不讨喜
生来不讨喜 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:09

    In the first example, the {} are used to identify multiple lines of code, which is why the return is required in order to obtain something other than undefined.

    In the second example, the {} are used to create an object.

提交回复
热议问题