<p dir="auto">Hi, i have example of own defined hook which returns always memorized callback <code class="notranslate">setValue</code>:</p>
<p dir="auto"><strong>Problem</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="   const [value, setValue] = useAppState( ... );
"><pre class="notranslate"><code class="notranslate">   const [value, setValue] = useAppState( ... );

</code></pre></div>
<p dir="auto">Then <code class="notranslate">setValue</code> used in hook which required deps, for example useEffect:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    useEffect(() =&gt; {
        if (value != 'a') {
            setValue('a');
        }
    }, [value]);"><pre class="notranslate"><code class="notranslate">    useEffect(() =&gt; {
        if (value != 'a') {
            setValue('a');
        }
    }, [value]);
</code></pre></div>
<p dir="auto">But unlike 'useState' this generates an error:</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/5655858/158798838-82fb7ffe-9907-4db2-8276-3230a68610a8.png"><img src="https://user-images.githubusercontent.com/5655858/158798838-82fb7ffe-9907-4db2-8276-3230a68610a8.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">I am found source which contain function to check this here:</p>
<p dir="auto"><a href="https://github.com/facebook/react/blob/9198a5cec0936a21a5ba194a22fcbac03eba5d1d/packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js">https://github.com/facebook/react/blob/9198a5cec0936a21a5ba194a22fcbac03eba5d1d/packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js</a></p>
<p dir="auto"><strong>Suggestion</strong><br>
Add configuration options to set own hooks to be handled as out of the box</p>
<p dir="auto">Right now only <code class="notranslate">useRef</code> and other first-party hooks are allowed to return a stable result that is not required to be listed in the dependencies array of other hooks.</p>
<p dir="auto">We have the <code class="notranslate">react-hooks/exhaustive-deps</code>' <code class="notranslate">additionalHooks</code> option to specify additional hooks that take dependencies arrays, but we don't have a way to describe a hook that returns a stable result.</p>
<p dir="auto">An example of such hook could be:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const useLatest = (value) =&gt; {
  const ref = useRef(value);
  ref.current = value;
  return ref;
};"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-en">useLatest</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span><span class="pl-s1">value</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
  <span class="pl-k">const</span> <span class="pl-s1">ref</span> <span class="pl-c1">=</span> <span class="pl-en">useRef</span><span class="pl-kos">(</span><span class="pl-s1">value</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-s1">ref</span><span class="pl-kos">.</span><span class="pl-c1">current</span> <span class="pl-c1">=</span> <span class="pl-s1">value</span><span class="pl-kos">;</span>
  <span class="pl-k">return</span> <span class="pl-s1">ref</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">It would be extremely useful being able to define custom hooks like this with a rule that could look like the following:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&quot;react-hooks/exhaustive-deps&quot;: [
  &quot;warn&quot;,
  {
    &quot;stableKnownHookValues&quot;: &quot;(useLatest|useSomethingElse)&quot;
  }
]"><pre class="notranslate"><code class="notranslate">"react-hooks/exhaustive-deps": [
  "warn",
  {
    "stableKnownHookValues": "(useLatest|useSomethingElse)"
  }
]
</code></pre></div>
<p dir="auto">I'd be willing to work on a PR if this idea is deemed useful.</p>