title: Trying to pass parameter back to custom hook to emit login data
body: <p>I have a login form component. I'm trying to pass <code>email</code> and <code>password</code> to a custom hook, where I emit the login information.</p>
  <p>I am having trouble getting the values into the custom hook which is in it's own <code>useSocket.js</code> file:</p>
  <pre><code>export function useLogIn() {
    const [email, setEmail] = useState();
    const [password, setPassword] = useState();
  
    useEffect(() =&gt; {
      if(email != &quot;&quot; &amp;&amp; password != &quot;&quot;)
      {
        socket.emit('signin', {&quot;inputEmail&quot;: email, &quot;inputPassword&quot;: password});
      }
    }, [])
  }
  </code></pre>
  <p>Here is the login component:</p>
  <pre><code>const LoginView = () =&gt; {
    const classes = useStyles();
    const navigate = useNavigate();
    const response = useIsLoggedIn();
    const loginData = useLogIn();
  
    let email;
    let password;
  
    const checkLogin = () =&gt; {
      if (response ? response.success : false == true) {
        navigate(&quot;/app/dashboard&quot;);
      } else {
        navigate(&quot;/&quot;);
      }
    }
  
    const login = () =&gt; {
      loginData.setEmail(email);
      loginData.setPassword(password);
      console.log(&quot;email: &quot; + email);
      console.log(&quot;password: &quot; + password);
    }
  
    //listen to login and update page
    useEffect(checkLogin, response ? response.success : false);
  </code></pre>
  <p>And here is what happens when the form submits:</p>
  <pre><code>initialValues={{
                email: email,
                password: password
              }}
  onSubmit={() =&gt; {
                login();
              }}
  </code></pre>
  <p>Any help is appreciated, thank you.</p>