Which React lifecycle method can I use `this` in before the render function is called : <p>i was previously catching an error in my code using the component will mount method which is now being depreciated this was my code prevoiusly:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>   componentWillMount() {
   if (!this.context) {
        throw new Error('Error');
   }
}</code></pre>
</div>
</div>
</p>

<ul>
<li><p>I considered adding my code to the <code>constructor</code> but that would not work since i cant use <code>this.</code> in the constructor</p></li>
<li><p>I also considered considered other lifecycle methods such as <code>componentDidMount</code> but this is called after the render function</p></li>
</ul>

<p>what would be the best way to solve this issue? would it be bad practice to add my error catching code in the render function?</p>
