Declaring Const With Curly Braces in JSX

前端 未结 2 573
醉梦人生
醉梦人生 2021-02-05 03:27

I\'m just getting started with React Native and getting used to JSX syntax. Is that what I\'m talking about? Or am I talking about TypeScript? Or... ES6? Anyway...

I\'ve

2条回答
  •  后悔当初
    2021-02-05 03:53

    Yes this is destructuring assignment feature of ECMASCRIPT 6

    For Example :

    const { createElement } = React
    const { render } = ReactDOM
    
    const title = createElement('h1', {id: 'title', className: 'header'}, 'Hello World')
    
    render(title, document.getElementById('react-container'))
    

    here ^

    React == { 
      cloneElement  : function(){ ... },
      createElement : function(){ ... },
      createFactory : function(){ ... }, 
    ... }
    

提交回复
热议问题