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

后端 未结 5 1048
梦谈多话
梦谈多话 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:11

    Another tip - if using the implied return shorthand, i.e.:

    foo => foo.bar

    you are able to write the return expression as multi-line. The only catch is you must include () around the expression. This happens often in React, for example, to improve JSX readability

    const myButton = props => (
      
    )
    

提交回复
热议问题