title: In React, can you use useState variable_1 as default value for another useState variable_2?
body: <ol>
  <li><p>Can you use useState variable_1 as default value for another useState variable_2, especially when variable_1 is being set by useEffect?</p>
  </li>
  <li><p>Even simpler, can you use useState variable_1 as default value for another useState variable_2 (without the useEffect dependency)?</p>
  </li>
  </ol>
  <p>To elaborate, here's an example</p>
  <pre><code>const [firstName, setFirstName] = useState(&quot;DEFAULT_NAME&quot;);
  const [fullName, setFullName] = useState(firstName); //is doing this permissible?
  
  useEffect(() =&gt; {
    setFirstName(&quot;REAL_NAME&quot;)
  }, []);
  
  console.log(fullName); // what would be printed here?
  </code></pre>
  <p>What would the value of <code>fullName</code> be? Would it be set to <code>&quot;DEFAULT_NAME&quot;</code> (signaling that it was set BEFORE the useEffect was called) or be set to <code>&quot;REAL_NAME&quot;</code> (signaling that it was set AFTER the useEffect was called)?</p>