title: React Native - How to initialize object in class component?
body: <p>I got this error message when I'm trying to initialize an object in the class component.</p>
  
  <p>Error message</p>
  
  <pre><code>    Failed to load bundle(http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false) with error:(SyntaxError: /blockchain/node_modules/react-native/App.js: Unexpected token (9:6)
  </code></pre>
  
  <p>My code</p>
  
  <p>App.js</p>
  
  <pre><code>import Block from './block.js'
  
  export default class App extends Component {
  
    let genesisBlock = new Block(); //error here
    let blockchain = new Blockchain(genesisBlock);
  
    render() {
      return (
        &lt;/View&gt;
  
      );
    }
  }
  </code></pre>
  
  <p>block.js</p>
  
  <pre><code>export default class Block {
      constructor() {
          this.index = 0
          this.previousHash = ""
          this.hash = ""
          this.nonce = 0
          this.transactions = []
       }
  
       addTransaction(transaction) {
          this.transactions.push(transaction)
      }
  
      get key() {
          return JSON.stringify(this.transactions) + this.index + this.previousHash + this.nonce
      }
  }
  </code></pre>
  
  <p>But if I remove <code>let</code>, it said <code>variable genesisBlock not found</code>.</p>
  
  <p>Reference: <a href="https://github.com/datomnurdin/blockchain-reactnative" rel="nofollow noreferrer">https://github.com/datomnurdin/blockchain-reactnative</a></p>