Syntax of fat arrow functions (=>), to use or not to use {} around the body

后端 未结 5 1051
梦谈多话
梦谈多话 2020-12-07 04:40

I am looking at this code - https://facebook.github.io/react-native/docs/network.html

return fetch(\'https://facebook.github.io/react-native/movies.json\')
          


        
5条回答
  •  长情又很酷
    2020-12-07 05:17

    (foo) => 'bar';

    does exactly the same thing as

    (foo) => {
      return 'bar';
    };
    

    If your function is multiline, use the second form.

    Here are some docs: MDN Arrow function

提交回复
热议问题