<p dir="auto">feature request:  getState, example, const [state, setState, getState] = useState(null);</p>
<p dir="auto">it is ok to use the simple variable in a dependent uses effect, but not ok in not a dependant use effect.</p>
<p dir="auto">the state is a simple variable. which is closure passed into functions, so it is not updated.<br>
and setState with a function argument is asynchronously dispatched.<br>
I suggest adding a synchronous function getState.</p>
<p dir="auto">it will be useful in simple js functions that are defined in useEffect for integration with not react js</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
  const [audioTrack, setAudioTrack] = useState(null);
  const [savedSelectedAudioTrack, setSavedSelectedAudioTrack] = useState(null);
  const [audioContext, setAudioContext] = useState(null);

// use useEffect to run once
useEffect( () =&gt;{
const handleParticipant = (participant) =&gt; {

          const availableTracks = Array.from(
            participant.tracks.values()
          ).filter(
            (publication) =&gt; publication.isSubscribed,
          ).map(
            (publication) =&gt; publication.track,
          );

          const audioTracks = availableTracks.filter(
            (track) =&gt; track.kind === 'audio',
          );
          
          const selectedAudioTrack =
            audioTracks.length === 0 ? null : audioTracks[0];

          if (selectedAudioTrack !== savedSelectedAudioTrack) { // here savedSelectedAudioTrack will not work
            setSavedSelectedAudioTrack(selectedAudioTrack);
            if (audioContext)
              setAudioTrack(
                // eslint-disable-next-line prettier/prettier
                audioContext.MediaStreamAudioSourceNode(selectedAudioTrack)
              );
            else setTimeout(() =&gt; handleParticipant(participant), 100);

            // setSelectedAudioTrack(selectedAudioTrack1);
            window.hasAudioTrack = true;
          } else {
            window.hasAudioTrack = false;
          }


          console.log(
            'audioTracks.length:',
            audioTracks.length
          );
  };


  // create audiocontext and 3rd parity library and add event handler to 3rd parity library
 setAudioContext(createdAudioContext);
 3rdParityLibrary.handleEvent=handleParticipant ;
} ,[])"><pre class="notranslate">  <span class="pl-k">const</span> <span class="pl-kos">[</span><span class="pl-s1">audioTrack</span><span class="pl-kos">,</span> <span class="pl-s1">setAudioTrack</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-en">useState</span><span class="pl-kos">(</span><span class="pl-c1">null</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-k">const</span> <span class="pl-kos">[</span><span class="pl-s1">savedSelectedAudioTrack</span><span class="pl-kos">,</span> <span class="pl-s1">setSavedSelectedAudioTrack</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-en">useState</span><span class="pl-kos">(</span><span class="pl-c1">null</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-k">const</span> <span class="pl-kos">[</span><span class="pl-s1">audioContext</span><span class="pl-kos">,</span> <span class="pl-s1">setAudioContext</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-en">useState</span><span class="pl-kos">(</span><span class="pl-c1">null</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-c">// use useEffect to run once</span>
<span class="pl-en">useEffect</span><span class="pl-kos">(</span> <span class="pl-kos">(</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-en">handleParticipant</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span><span class="pl-s1">participant</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">availableTracks</span> <span class="pl-c1">=</span> <span class="pl-v">Array</span><span class="pl-kos">.</span><span class="pl-en">from</span><span class="pl-kos">(</span>
            <span class="pl-s1">participant</span><span class="pl-kos">.</span><span class="pl-c1">tracks</span><span class="pl-kos">.</span><span class="pl-en">values</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
          <span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">filter</span><span class="pl-kos">(</span>
            <span class="pl-kos">(</span><span class="pl-s1">publication</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-s1">publication</span><span class="pl-kos">.</span><span class="pl-c1">isSubscribed</span><span class="pl-kos">,</span>
          <span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">map</span><span class="pl-kos">(</span>
            <span class="pl-kos">(</span><span class="pl-s1">publication</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-s1">publication</span><span class="pl-kos">.</span><span class="pl-c1">track</span><span class="pl-kos">,</span>
          <span class="pl-kos">)</span><span class="pl-kos">;</span>

          <span class="pl-k">const</span> <span class="pl-s1">audioTracks</span> <span class="pl-c1">=</span> <span class="pl-s1">availableTracks</span><span class="pl-kos">.</span><span class="pl-en">filter</span><span class="pl-kos">(</span>
            <span class="pl-kos">(</span><span class="pl-s1">track</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-s1">track</span><span class="pl-kos">.</span><span class="pl-c1">kind</span> <span class="pl-c1">===</span> <span class="pl-s">'audio'</span><span class="pl-kos">,</span>
          <span class="pl-kos">)</span><span class="pl-kos">;</span>
          
          <span class="pl-k">const</span> <span class="pl-s1">selectedAudioTrack</span> <span class="pl-c1">=</span>
            <span class="pl-s1">audioTracks</span><span class="pl-kos">.</span><span class="pl-c1">length</span> <span class="pl-c1">===</span> <span class="pl-c1">0</span> ? <span class="pl-c1">null</span> : <span class="pl-s1">audioTracks</span><span class="pl-kos">[</span><span class="pl-c1">0</span><span class="pl-kos">]</span><span class="pl-kos">;</span>

          <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">selectedAudioTrack</span> <span class="pl-c1">!==</span> <span class="pl-s1">savedSelectedAudioTrack</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-c">// here savedSelectedAudioTrack will not work</span>
            <span class="pl-s1">setSavedSelectedAudioTrack</span><span class="pl-kos">(</span><span class="pl-s1">selectedAudioTrack</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
            <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">audioContext</span><span class="pl-kos">)</span>
              <span class="pl-s1">setAudioTrack</span><span class="pl-kos">(</span>
                <span class="pl-c">// eslint-disable-next-line prettier/prettier</span>
                <span class="pl-s1">audioContext</span><span class="pl-kos">.</span><span class="pl-en">MediaStreamAudioSourceNode</span><span class="pl-kos">(</span><span class="pl-s1">selectedAudioTrack</span><span class="pl-kos">)</span>
              <span class="pl-kos">)</span><span class="pl-kos">;</span>
            <span class="pl-k">else</span> <span class="pl-en">setTimeout</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-en">handleParticipant</span><span class="pl-kos">(</span><span class="pl-s1">participant</span><span class="pl-kos">)</span><span class="pl-kos">,</span> <span class="pl-c1">100</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

            <span class="pl-c">// setSelectedAudioTrack(selectedAudioTrack1);</span>
            <span class="pl-smi">window</span><span class="pl-kos">.</span><span class="pl-c1">hasAudioTrack</span> <span class="pl-c1">=</span> <span class="pl-c1">true</span><span class="pl-kos">;</span>
          <span class="pl-kos">}</span> <span class="pl-k">else</span> <span class="pl-kos">{</span>
            <span class="pl-smi">window</span><span class="pl-kos">.</span><span class="pl-c1">hasAudioTrack</span> <span class="pl-c1">=</span> <span class="pl-c1">false</span><span class="pl-kos">;</span>
          <span class="pl-kos">}</span>


          <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span>
            <span class="pl-s">'audioTracks.length:'</span><span class="pl-kos">,</span>
            <span class="pl-s1">audioTracks</span><span class="pl-kos">.</span><span class="pl-c1">length</span>
          <span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span><span class="pl-kos">;</span>


  <span class="pl-c">// create audiocontext and 3rd parity library and add event handler to 3rd parity library</span>
 <span class="pl-s1">setAudioContext</span><span class="pl-kos">(</span><span class="pl-s1">createdAudioContext</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
 <span class="pl-c1">3</span><span class="pl-kos"></span><span class="pl-s1">rdParityLibrary</span><span class="pl-kos">.</span><span class="pl-c1">handleEvent</span><span class="pl-c1">=</span><span class="pl-en">handleParticipant</span> <span class="pl-kos">;</span>
<span class="pl-kos">}</span> <span class="pl-kos">,</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">)</span></pre></div>
<p dir="auto">but the working implementation is like</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
  const [audioTrack, setAudioTrack] = useState(null);
  const [savedSelectedAudioTrack, setSavedSelectedAudioTrack] = useState(null);
  const [audioContext, setAudioContext] = useState(null);

// use useEffect to run once
useEffect( () =&gt;{
const handleParticipant = (participant) =&gt; {

      setSavedSelectedAudioTrack((savedSelectedAudioTrack) =&gt; {
        setAudioContext((audioContext) =&gt; {

          const availableTracks = Array.from(
            participant.tracks.values()
          ).filter(
            (publication) =&gt; publication.isSubscribed,
          ).map(
            (publication) =&gt; publication.track,
          );

          const audioTracks = availableTracks.filter(
            (track) =&gt; track.kind === 'audio',
          );
          
          const selectedAudioTrack =
            audioTracks.length === 0 ? null : audioTracks[0];

          if (selectedAudioTrack !== savedSelectedAudioTrack) { // here savedSelectedAudioTrack will not work
            setSavedSelectedAudioTrack(selectedAudioTrack);
            if (audioContext) // and audio context also will not work
              setAudioTrack(
                // eslint-disable-next-line prettier/prettier
                audioContext.MediaStreamAudioSourceNode(selectedAudioTrack)
              );
            else setTimeout(() =&gt; handleParticipant(participant), 100);

            // setSelectedAudioTrack(selectedAudioTrack1);
            window.hasAudioTrack = true;
          } else {
            window.hasAudioTrack = false;
          }


          console.log(
            'audioTracks.length:',
            audioTracks.length
          );
          
          
          return audioContext;
        });
        return savedSelectedAudioTrack;
      });
  };


  // create audiocontext and 3rd parity library and add event handler to 3rd parity library
 setAudioContext(createdAudioContext);
 3rdParityLibrary.handleEvent=handleParticipant ;
} ,[])"><pre class="notranslate">  <span class="pl-k">const</span> <span class="pl-kos">[</span><span class="pl-s1">audioTrack</span><span class="pl-kos">,</span> <span class="pl-s1">setAudioTrack</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-en">useState</span><span class="pl-kos">(</span><span class="pl-c1">null</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-k">const</span> <span class="pl-kos">[</span><span class="pl-s1">savedSelectedAudioTrack</span><span class="pl-kos">,</span> <span class="pl-s1">setSavedSelectedAudioTrack</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-en">useState</span><span class="pl-kos">(</span><span class="pl-c1">null</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-k">const</span> <span class="pl-kos">[</span><span class="pl-s1">audioContext</span><span class="pl-kos">,</span> <span class="pl-s1">setAudioContext</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-en">useState</span><span class="pl-kos">(</span><span class="pl-c1">null</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-c">// use useEffect to run once</span>
<span class="pl-en">useEffect</span><span class="pl-kos">(</span> <span class="pl-kos">(</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-en">handleParticipant</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span><span class="pl-s1">participant</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>

      <span class="pl-s1">setSavedSelectedAudioTrack</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-s1">savedSelectedAudioTrack</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
        <span class="pl-s1">setAudioContext</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-s1">audioContext</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">availableTracks</span> <span class="pl-c1">=</span> <span class="pl-v">Array</span><span class="pl-kos">.</span><span class="pl-en">from</span><span class="pl-kos">(</span>
            <span class="pl-s1">participant</span><span class="pl-kos">.</span><span class="pl-c1">tracks</span><span class="pl-kos">.</span><span class="pl-en">values</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
          <span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">filter</span><span class="pl-kos">(</span>
            <span class="pl-kos">(</span><span class="pl-s1">publication</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-s1">publication</span><span class="pl-kos">.</span><span class="pl-c1">isSubscribed</span><span class="pl-kos">,</span>
          <span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">map</span><span class="pl-kos">(</span>
            <span class="pl-kos">(</span><span class="pl-s1">publication</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-s1">publication</span><span class="pl-kos">.</span><span class="pl-c1">track</span><span class="pl-kos">,</span>
          <span class="pl-kos">)</span><span class="pl-kos">;</span>

          <span class="pl-k">const</span> <span class="pl-s1">audioTracks</span> <span class="pl-c1">=</span> <span class="pl-s1">availableTracks</span><span class="pl-kos">.</span><span class="pl-en">filter</span><span class="pl-kos">(</span>
            <span class="pl-kos">(</span><span class="pl-s1">track</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-s1">track</span><span class="pl-kos">.</span><span class="pl-c1">kind</span> <span class="pl-c1">===</span> <span class="pl-s">'audio'</span><span class="pl-kos">,</span>
          <span class="pl-kos">)</span><span class="pl-kos">;</span>
          
          <span class="pl-k">const</span> <span class="pl-s1">selectedAudioTrack</span> <span class="pl-c1">=</span>
            <span class="pl-s1">audioTracks</span><span class="pl-kos">.</span><span class="pl-c1">length</span> <span class="pl-c1">===</span> <span class="pl-c1">0</span> ? <span class="pl-c1">null</span> : <span class="pl-s1">audioTracks</span><span class="pl-kos">[</span><span class="pl-c1">0</span><span class="pl-kos">]</span><span class="pl-kos">;</span>

          <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">selectedAudioTrack</span> <span class="pl-c1">!==</span> <span class="pl-s1">savedSelectedAudioTrack</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-c">// here savedSelectedAudioTrack will not work</span>
            <span class="pl-s1">setSavedSelectedAudioTrack</span><span class="pl-kos">(</span><span class="pl-s1">selectedAudioTrack</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
            <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">audioContext</span><span class="pl-kos">)</span> <span class="pl-c">// and audio context also will not work</span>
              <span class="pl-s1">setAudioTrack</span><span class="pl-kos">(</span>
                <span class="pl-c">// eslint-disable-next-line prettier/prettier</span>
                <span class="pl-s1">audioContext</span><span class="pl-kos">.</span><span class="pl-en">MediaStreamAudioSourceNode</span><span class="pl-kos">(</span><span class="pl-s1">selectedAudioTrack</span><span class="pl-kos">)</span>
              <span class="pl-kos">)</span><span class="pl-kos">;</span>
            <span class="pl-k">else</span> <span class="pl-en">setTimeout</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-en">handleParticipant</span><span class="pl-kos">(</span><span class="pl-s1">participant</span><span class="pl-kos">)</span><span class="pl-kos">,</span> <span class="pl-c1">100</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

            <span class="pl-c">// setSelectedAudioTrack(selectedAudioTrack1);</span>
            <span class="pl-smi">window</span><span class="pl-kos">.</span><span class="pl-c1">hasAudioTrack</span> <span class="pl-c1">=</span> <span class="pl-c1">true</span><span class="pl-kos">;</span>
          <span class="pl-kos">}</span> <span class="pl-k">else</span> <span class="pl-kos">{</span>
            <span class="pl-smi">window</span><span class="pl-kos">.</span><span class="pl-c1">hasAudioTrack</span> <span class="pl-c1">=</span> <span class="pl-c1">false</span><span class="pl-kos">;</span>
          <span class="pl-kos">}</span>


          <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span>
            <span class="pl-s">'audioTracks.length:'</span><span class="pl-kos">,</span>
            <span class="pl-s1">audioTracks</span><span class="pl-kos">.</span><span class="pl-c1">length</span>
          <span class="pl-kos">)</span><span class="pl-kos">;</span>
          
          
          <span class="pl-k">return</span> <span class="pl-s1">audioContext</span><span class="pl-kos">;</span>
        <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-k">return</span> <span class="pl-s1">savedSelectedAudioTrack</span><span class="pl-kos">;</span>
      <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span><span class="pl-kos">;</span>


  <span class="pl-c">// create audiocontext and 3rd parity library and add event handler to 3rd parity library</span>
 <span class="pl-s1">setAudioContext</span><span class="pl-kos">(</span><span class="pl-s1">createdAudioContext</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
 <span class="pl-c1">3</span><span class="pl-kos"></span><span class="pl-s1">rdParityLibrary</span><span class="pl-kos">.</span><span class="pl-c1">handleEvent</span><span class="pl-c1">=</span><span class="pl-en">handleParticipant</span> <span class="pl-kos">;</span>
<span class="pl-kos">}</span> <span class="pl-kos">,</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">)</span></pre></div>
<p dir="auto">i wish there was  a synchronous getState.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
  const [audioTrack, setAudioTrack] = useState(null);
  const [savedSelectedAudioTrack, setSavedSelectedAudioTrack, getSavedSelectedAudioTrack] = useState(null);
  const [audioContext, setAudioContext, getAudioContext] = useState(null);

// use useEffect to run once
useEffect( () =&gt;{
const handleParticipant = (participant) =&gt; {

          const availableTracks = Array.from(
            participant.tracks.values()
          ).filter(
            (publication) =&gt; publication.isSubscribed,
          ).map(
            (publication) =&gt; publication.track,
          );

          const audioTracks = availableTracks.filter(
            (track) =&gt; track.kind === 'audio',
          );
          
          const selectedAudioTrack =
            audioTracks.length === 0 ? null : audioTracks[0];

          if (selectedAudioTrack !== getSavedSelectedAudioTrack()) { // here savedSelectedAudioTrack will not work
            setSavedSelectedAudioTrack(selectedAudioTrack);
            if (getAudioContext())
              setAudioTrack(
                getAudioContext().MediaStreamAudioSourceNode(selectedAudioTrack)
              );
            else setTimeout(() =&gt; handleParticipant(participant), 100);

            // setSelectedAudioTrack(selectedAudioTrack1);
            window.hasAudioTrack = true;
          } else {
            window.hasAudioTrack = false;
          }


          console.log(
            'audioTracks.length:',
            audioTracks.length
          );
  };


  // create audiocontext and 3rd parity library and add event handler to 3rd parity library
 setAudioContext(createdAudioContext);
 3rdParityLibrary.handleEvent=handleParticipant ;
} ,[])"><pre class="notranslate">  <span class="pl-k">const</span> <span class="pl-kos">[</span><span class="pl-s1">audioTrack</span><span class="pl-kos">,</span> <span class="pl-s1">setAudioTrack</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-en">useState</span><span class="pl-kos">(</span><span class="pl-c1">null</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-k">const</span> <span class="pl-kos">[</span><span class="pl-s1">savedSelectedAudioTrack</span><span class="pl-kos">,</span> <span class="pl-s1">setSavedSelectedAudioTrack</span><span class="pl-kos">,</span> <span class="pl-s1">getSavedSelectedAudioTrack</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-en">useState</span><span class="pl-kos">(</span><span class="pl-c1">null</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-k">const</span> <span class="pl-kos">[</span><span class="pl-s1">audioContext</span><span class="pl-kos">,</span> <span class="pl-s1">setAudioContext</span><span class="pl-kos">,</span> <span class="pl-s1">getAudioContext</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-en">useState</span><span class="pl-kos">(</span><span class="pl-c1">null</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-c">// use useEffect to run once</span>
<span class="pl-en">useEffect</span><span class="pl-kos">(</span> <span class="pl-kos">(</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-en">handleParticipant</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span><span class="pl-s1">participant</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">availableTracks</span> <span class="pl-c1">=</span> <span class="pl-v">Array</span><span class="pl-kos">.</span><span class="pl-en">from</span><span class="pl-kos">(</span>
            <span class="pl-s1">participant</span><span class="pl-kos">.</span><span class="pl-c1">tracks</span><span class="pl-kos">.</span><span class="pl-en">values</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
          <span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">filter</span><span class="pl-kos">(</span>
            <span class="pl-kos">(</span><span class="pl-s1">publication</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-s1">publication</span><span class="pl-kos">.</span><span class="pl-c1">isSubscribed</span><span class="pl-kos">,</span>
          <span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">map</span><span class="pl-kos">(</span>
            <span class="pl-kos">(</span><span class="pl-s1">publication</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-s1">publication</span><span class="pl-kos">.</span><span class="pl-c1">track</span><span class="pl-kos">,</span>
          <span class="pl-kos">)</span><span class="pl-kos">;</span>

          <span class="pl-k">const</span> <span class="pl-s1">audioTracks</span> <span class="pl-c1">=</span> <span class="pl-s1">availableTracks</span><span class="pl-kos">.</span><span class="pl-en">filter</span><span class="pl-kos">(</span>
            <span class="pl-kos">(</span><span class="pl-s1">track</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-s1">track</span><span class="pl-kos">.</span><span class="pl-c1">kind</span> <span class="pl-c1">===</span> <span class="pl-s">'audio'</span><span class="pl-kos">,</span>
          <span class="pl-kos">)</span><span class="pl-kos">;</span>
          
          <span class="pl-k">const</span> <span class="pl-s1">selectedAudioTrack</span> <span class="pl-c1">=</span>
            <span class="pl-s1">audioTracks</span><span class="pl-kos">.</span><span class="pl-c1">length</span> <span class="pl-c1">===</span> <span class="pl-c1">0</span> ? <span class="pl-c1">null</span> : <span class="pl-s1">audioTracks</span><span class="pl-kos">[</span><span class="pl-c1">0</span><span class="pl-kos">]</span><span class="pl-kos">;</span>

          <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">selectedAudioTrack</span> <span class="pl-c1">!==</span> <span class="pl-s1">getSavedSelectedAudioTrack</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-c">// here savedSelectedAudioTrack will not work</span>
            <span class="pl-s1">setSavedSelectedAudioTrack</span><span class="pl-kos">(</span><span class="pl-s1">selectedAudioTrack</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
            <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">getAudioContext</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">)</span>
              <span class="pl-s1">setAudioTrack</span><span class="pl-kos">(</span>
                <span class="pl-s1">getAudioContext</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">MediaStreamAudioSourceNode</span><span class="pl-kos">(</span><span class="pl-s1">selectedAudioTrack</span><span class="pl-kos">)</span>
              <span class="pl-kos">)</span><span class="pl-kos">;</span>
            <span class="pl-k">else</span> <span class="pl-en">setTimeout</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-en">handleParticipant</span><span class="pl-kos">(</span><span class="pl-s1">participant</span><span class="pl-kos">)</span><span class="pl-kos">,</span> <span class="pl-c1">100</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

            <span class="pl-c">// setSelectedAudioTrack(selectedAudioTrack1);</span>
            <span class="pl-smi">window</span><span class="pl-kos">.</span><span class="pl-c1">hasAudioTrack</span> <span class="pl-c1">=</span> <span class="pl-c1">true</span><span class="pl-kos">;</span>
          <span class="pl-kos">}</span> <span class="pl-k">else</span> <span class="pl-kos">{</span>
            <span class="pl-smi">window</span><span class="pl-kos">.</span><span class="pl-c1">hasAudioTrack</span> <span class="pl-c1">=</span> <span class="pl-c1">false</span><span class="pl-kos">;</span>
          <span class="pl-kos">}</span>


          <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span>
            <span class="pl-s">'audioTracks.length:'</span><span class="pl-kos">,</span>
            <span class="pl-s1">audioTracks</span><span class="pl-kos">.</span><span class="pl-c1">length</span>
          <span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span><span class="pl-kos">;</span>


  <span class="pl-c">// create audiocontext and 3rd parity library and add event handler to 3rd parity library</span>
 <span class="pl-s1">setAudioContext</span><span class="pl-kos">(</span><span class="pl-s1">createdAudioContext</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
 <span class="pl-c1">3</span><span class="pl-kos"></span><span class="pl-s1">rdParityLibrary</span><span class="pl-kos">.</span><span class="pl-c1">handleEvent</span><span class="pl-c1">=</span><span class="pl-en">handleParticipant</span> <span class="pl-kos">;</span>
<span class="pl-kos">}</span> <span class="pl-kos">,</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">)</span></pre></div>
<h2 dir="auto">Steps To Reproduce</h2>
<p dir="auto">Englobe code in a static class make rule bug !<br>
Actually rule detect React in class, but it not true !<br>
This is a pure ES6 js class with a proxi field to a React functions in scope.<br>
And is not a React Class components !</p>
<div class="highlight highlight-source-tsx notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="interface PanelProps {}
class DOMAINE {
	static Panel : FC&lt;PanelProps&gt; = (props)=&gt; {
		const { children } = props;
		const state = useState&lt;unknown&gt;(null);
	
		useEffect(() =&gt; {});
		return (
			&lt;Bloc className='Panel' Flex Grow&gt;
				{children}
			&lt;/Bloc&gt;
		);
	};
	static a = class ACTIVITY {
		static Panel : VFC&lt;PanelProps&gt; = (props)=&gt; {
			const {  } = props;
			const state = useState&lt;unknown&gt;(null);
		
			useEffect(() =&gt; {});
			return (
				&lt;Bloc className='Panel' Flex Grow&gt;
					
				&lt;/Bloc&gt;
			);
		};
	}
}
"><pre class="notranslate"><span class="pl-k">interface</span> <span class="pl-smi">PanelProps</span> <span class="pl-kos">{</span><span class="pl-kos">}</span>
<span class="pl-k">class</span> <span class="pl-smi">DOMAINE</span> <span class="pl-kos">{</span>
	<span class="pl-k">static</span> <span class="pl-c1">Panel</span> : <span class="pl-smi">FC</span><span class="pl-kos">&lt;</span><span class="pl-smi">PanelProps</span><span class="pl-kos">&gt;</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span><span class="pl-s1">props</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-kos">{</span> children <span class="pl-kos">}</span> <span class="pl-c1">=</span> <span class="pl-s1">props</span><span class="pl-kos">;</span>
		<span class="pl-k">const</span> <span class="pl-s1">state</span> <span class="pl-c1">=</span> <span class="pl-en">useState</span><span class="pl-kos">&lt;</span><span class="pl-smi">unknown</span><span class="pl-kos">&gt;</span><span class="pl-kos">(</span><span class="pl-c1">null</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
	
		<span class="pl-en">useEffect</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
		<span class="pl-k">return</span> <span class="pl-kos">(</span>
			<span class="pl-c1">&lt;</span><span class="pl-smi">Bloc</span> <span class="pl-c1">className</span><span class="pl-c1">=</span><span class="pl-s">'Panel'</span> <span class="pl-c1">Flex</span> <span class="pl-c1">Grow</span><span class="pl-c1">&gt;</span>
				<span class="pl-kos">{</span><span class="pl-s1">children</span><span class="pl-kos">}</span>
			<span class="pl-c1">&lt;</span><span class="pl-c1">/</span><span class="pl-smi">Bloc</span><span class="pl-c1">&gt;</span>
		<span class="pl-kos">)</span><span class="pl-kos">;</span>
	<span class="pl-kos">}</span><span class="pl-kos">;</span>
	<span class="pl-k">static</span> <span class="pl-c1">a</span> <span class="pl-c1">=</span> <span class="pl-k">class</span> <span class="pl-smi">ACTIVITY</span> <span class="pl-kos">{</span>
		<span class="pl-k">static</span> <span class="pl-c1">Panel</span> : <span class="pl-smi">VFC</span><span class="pl-kos">&lt;</span><span class="pl-smi">PanelProps</span><span class="pl-kos">&gt;</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span><span class="pl-s1">props</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-kos">{</span>  <span class="pl-kos">}</span> <span class="pl-c1">=</span> <span class="pl-s1">props</span><span class="pl-kos">;</span>
			<span class="pl-k">const</span> <span class="pl-s1">state</span> <span class="pl-c1">=</span> <span class="pl-en">useState</span><span class="pl-kos">&lt;</span><span class="pl-smi">unknown</span><span class="pl-kos">&gt;</span><span class="pl-kos">(</span><span class="pl-c1">null</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
		
			<span class="pl-en">useEffect</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
			<span class="pl-k">return</span> <span class="pl-kos">(</span>
				<span class="pl-c1">&lt;</span><span class="pl-smi">Bloc</span> <span class="pl-c1">className</span><span class="pl-c1">=</span><span class="pl-s">'Panel'</span> <span class="pl-c1">Flex</span> <span class="pl-c1">Grow</span><span class="pl-c1">&gt;</span>
					
				<span class="pl-c1">&lt;</span><span class="pl-c1">/</span><span class="pl-smi">Bloc</span><span class="pl-c1">&gt;</span>
			<span class="pl-kos">)</span><span class="pl-kos">;</span>
		<span class="pl-kos">}</span><span class="pl-kos">;</span>
	<span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/24865815/135672118-097b4751-e6bd-4922-96ed-6b6193609c2c.png"><img src="https://user-images.githubusercontent.com/24865815/135672118-097b4751-e6bd-4922-96ed-6b6193609c2c.png" alt="image" style="max-width: 100%;"></a></p>

<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
    &quot;env&quot;: {
        &quot;browser&quot;: true,
        &quot;es2021&quot;: true,
        &quot;node&quot;: true
    },
    &quot;extends&quot;: [
        &quot;plugin:react/recommended&quot;,
        &quot;plugin:react-hooks/recommended&quot;
    ],
    &quot;parser&quot;: &quot;@typescript-eslint/parser&quot;,
    &quot;parserOptions&quot;: {
        &quot;ecmaFeatures&quot;: {
            &quot;jsx&quot;: true
        },
        &quot;ecmaVersion&quot;: 12,
        &quot;sourceType&quot;: &quot;module&quot;
    },
    &quot;plugins&quot;: [
        &quot;react&quot;,
        &quot;@typescript-eslint&quot;
    ],
    &quot;rules&quot;: {
        &quot;array-bracket-spacing&quot;: &quot;warn&quot;,
        &quot;multiline-comment-style&quot;: &quot;warn&quot;,
        &quot;no-console&quot;: &quot;warn&quot;,
        &quot;comma-dangle&quot;: &quot;off&quot;,
        &quot;no-var&quot;: &quot;warn&quot;,
        &quot;no-duplicate-imports&quot;: &quot;error&quot;
    }
}"><pre class="notranslate">{
    <span class="pl-ent">"env"</span>: {
        <span class="pl-ent">"browser"</span>: <span class="pl-c1">true</span>,
        <span class="pl-ent">"es2021"</span>: <span class="pl-c1">true</span>,
        <span class="pl-ent">"node"</span>: <span class="pl-c1">true</span>
    },
    <span class="pl-ent">"extends"</span>: [
        <span class="pl-s"><span class="pl-pds">"</span>plugin:react/recommended<span class="pl-pds">"</span></span>,
        <span class="pl-s"><span class="pl-pds">"</span>plugin:react-hooks/recommended<span class="pl-pds">"</span></span>
    ],
    <span class="pl-ent">"parser"</span>: <span class="pl-s"><span class="pl-pds">"</span>@typescript-eslint/parser<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"parserOptions"</span>: {
        <span class="pl-ent">"ecmaFeatures"</span>: {
            <span class="pl-ent">"jsx"</span>: <span class="pl-c1">true</span>
        },
        <span class="pl-ent">"ecmaVersion"</span>: <span class="pl-c1">12</span>,
        <span class="pl-ent">"sourceType"</span>: <span class="pl-s"><span class="pl-pds">"</span>module<span class="pl-pds">"</span></span>
    },
    <span class="pl-ent">"plugins"</span>: [
        <span class="pl-s"><span class="pl-pds">"</span>react<span class="pl-pds">"</span></span>,
        <span class="pl-s"><span class="pl-pds">"</span>@typescript-eslint<span class="pl-pds">"</span></span>
    ],
    <span class="pl-ent">"rules"</span>: {
        <span class="pl-ent">"array-bracket-spacing"</span>: <span class="pl-s"><span class="pl-pds">"</span>warn<span class="pl-pds">"</span></span>,
        <span class="pl-ent">"multiline-comment-style"</span>: <span class="pl-s"><span class="pl-pds">"</span>warn<span class="pl-pds">"</span></span>,
        <span class="pl-ent">"no-console"</span>: <span class="pl-s"><span class="pl-pds">"</span>warn<span class="pl-pds">"</span></span>,
        <span class="pl-ent">"comma-dangle"</span>: <span class="pl-s"><span class="pl-pds">"</span>off<span class="pl-pds">"</span></span>,
        <span class="pl-ent">"no-var"</span>: <span class="pl-s"><span class="pl-pds">"</span>warn<span class="pl-pds">"</span></span>,
        <span class="pl-ent">"no-duplicate-imports"</span>: <span class="pl-s"><span class="pl-pds">"</span>error<span class="pl-pds">"</span></span>
    }
}</pre></div>
<p dir="auto">Link to code example: <a href="https://codesandbox.io/s/currying-https-9v064?file=/src/App.js" rel="nofollow">https://codesandbox.io/s/currying-https-9v064?file=/src/App.js</a></p>

<h2 dir="auto">The current behavior</h2>
<p dir="auto">Rule think we use hooks inside a react Class !</p>
<h2 dir="auto">The expected behavior</h2>
<p dir="auto">Rule should not emit error about hooks for this structure</p>