title: How to use custom functions in a React class after it was rendered?
body: <p>Let's say that I create additional functions in my React components, something like this:</p>
  
  <pre><code>class Cart extends React.Component {
      render() {
         return &lt;div id="cart"&gt;My Cart Items&lt;/div&gt;
      }
      getItem(id) {
         // magically return the item
      }
      addItem(id, name, type, price){
         // you get the idea
      }
  }
  </code></pre>
  
  <p>Now, what is the best way to access <code>getItem</code> function from outside the class? For example, something that can be used as <code>window.Cart.getItem</code>. It seems to me that these functions are part of the <code>prototype</code> (non-initialized) of <code>nodeName</code> property of what <code>ReactDOM.render</code> returns.</p>
  
  <p>What is the correct way for this? Thanks.</p>