title: What are the reasons for use static contextTypes = {} in react components?
body: <p>I'm trying to understand some code. Can you please explain to me what is the purpose of doing this static contextTypes = {}? Why we define it like so? What are the benefits?</p>
  
  <pre><code>static contextTypes = {
    product_id: PropTypes.number,
    size: PropTypes.number,
    loadRelatedProducts: PropTypes.func,
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/o3QHm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o3QHm.png" alt="enter image description here"></a></p>
  
  <p>You can find full component code here -> <a href="https://jsfiddle.net/8hbyLopq/1/" rel="nofollow noreferrer">https://jsfiddle.net/8hbyLopq/1/</a></p>
  
  <hr>
  
  <p><strong>EDIT and information for developers from future:</strong></p>
  
  <p>So I read docs and it is type-checking.</p>
  
  <p>React docs says:</p>
  
  <blockquote>
    <p>PropTypes exports a range of validators that can be used to make sure
    the data you receive is valid. In this example, we’re using
    PropTypes.string. When an invalid value is provided for a prop, a
    warning will be shown in the JavaScript console.</p>
  </blockquote>
  
  <p>Questions about that:</p>
  
  <ol>
  <li><p>This type-checking is for props that are comming from RelatedProducts component parent, yes? So it is checking if RelatedProducts parent is sending us product.id that is a number? If not there will be console log error shown, right?</p></li>
  <li><p>It can also be used to check other inputs, because we are here importing a function loadRelatedProducts from a redux action, right?</p></li>
  <li><p>Did I forget about something concerning the matter?</p></li>
  </ol>