title: Incorrect use of react hooks but no hook errors/faults
body: <p>React hooks can only be used inside</p>
  <ul>
  <li>Functional components</li>
  <li>Other hooks</li>
  </ul>
  <p>If you don't follow the above rules, react complains about not following the rules via a fault</p>
  <p>But, the below code works (albeit with lint errors) without any stack-trace/errors</p>
  <pre><code>import React from 'react'
  import { useState, createContext, useContext } from &quot;react&quot;;
  
  const SomethingContext = createContext(&quot;what is the thing&quot;);
  
  // Correct usage
  const useSomething = () =&gt; {
    const something = useContext(SomethingContext);
    return something;
  };
  
  //Incorrect usage
  const getTheThing = () =&gt; {
    const theThing = useContext(SomethingContext); // works with useState as well (ex below)
    return theThing;
  };
  
  //Incorect usage
  const getTheThingState = () =&gt; {
    const [theThing, setTheThing] = useState(&quot;I am the state&quot;); 
    return theThing;
  };
  
  const Child = () =&gt; {
    const theThing = getTheThing(); //OR getTheThingState()
    return `The thing is &quot;${theThing}&quot;`;
  };
  
  export default function App() {
    return (
      &lt;div className=&quot;App&quot;&gt;
        &lt;SomethingContext.Provider value={&quot;it is something&quot;}&gt;
          &lt;Child /&gt;
        &lt;/SomethingContext.Provider&gt;
      &lt;/div&gt;
    );
  }
  </code></pre>
  <p>Here's a <a href="https://codesandbox.io/s/vigilant-bird-nu8ep" rel="nofollow noreferrer">demo</a> of the above code. The linter points out the incorrect usage, but the odd part where I'm confused is that <code>React</code> itself doesn't throw any error.</p>
  <p>Not able to figure out <strong>WHY?</strong></p>
  <p>All resources point out to fix the above problem by changing the function into a component i.e function's variable name (I'm aware of it)</p>
  <pre><code>const GetTheThing = () =&gt; {
  //...
  </code></pre>
  <p>But, when does react decide to say &quot;okay, you are not supposed to do that&quot; vs &quot;okay, I'll let this one slide&quot;.</p>