title: useState is resetting to default after initial and every subsequent render in ReactJS
body: <p>the below code is not returning any errors but is not working either as per the logic.</p>
  <p>So below are two components, APP() as parent component and Signin() as child component, in parent component i am use useEffect and whenever there is render happens it first check the server with cookies if valid then it will update the siginalready= true(initial default value is false) and then will pass the state to the child component, but when next  time i refresh the page it takes as siginalready=false   as initial value (which is odd as it should be true  already after first time).</p>
  <p>This behaviour of resetting the state value of  siginalready is effecting the project as when second time (i click account information it fist shows me the loginpage(siginalready =false) and then in less than a second it shows me the account info page((siginalready =true).
  i got a feeling that it is something i am missing with useEffect function,  but i dont see any thing wrong in it. any suggestions guys.</p>
  <p>this is the snippet from Parent component.</p>
  <pre><code>import Signin from &quot;./Component/Signin&quot;;
  
  function App() {
  
    const [siginalready, setifsignedin] = useState(false);
  
    const [userinfonew, setUserinfo] = useState([]);
  
  
  
    let url = &quot;http://localhost:5000/api/verifyifloginalready&quot;;
  
    let options = {
      credentials: &quot;include&quot;,
      method: &quot;POST&quot;,
    };
    let verifyifloginalready = new Request(url, options);
  
  
    useEffect(() =&gt; {
      credentailverify();
    }, []);
  
  
  
    function credentailverify() {
      (async () =&gt; {
        const x1 = await fetch(verifyifloginalready)
          .then((res) =&gt; {
            if (res.status == 400 || res.status == 401) {
              console.log(res.status);
              // to do call delete current  cookies function
              return setifsignedin(false);
            } else if (siginalready == false) {
              setifsignedin(true);
  
              return res.json();
            } else {
              return;
            }
          })
          .then((data) =&gt; {
            setUserinfo(data.data);
          })
          .catch((err) =&gt; console.log(&quot;err&quot;));
  
        return x1;
      })();
    }
  
    return (
      &lt;Router&gt;
        &lt;div className=&quot;App&quot;&gt;
          &lt;header className=&quot;header&quot;&gt;
            &lt;Nav userinfo={userinfonew} userstatus={siginalready} /&gt;
          &lt;/header&gt;
  
          &lt;div className=&quot;main&quot;&gt;
            &lt;Sidebar /&gt;
            &lt;Switch&gt;
              &lt;Route
                path=&quot;/&quot;
                exact
             
                render={(props) =&gt; &lt;Home {...props} userinfo={userinfonew} /&gt;}
              /&gt;
             
              from router {/* render={props=&gt;(&lt;newComponent}/&gt; )} */}
             
              /&gt;
              &lt;Route
                path=&quot;/signin&quot;
                exact
                render={(props) =&gt; (
                  &lt;Signin
                    {...props}
                    userinfo={userinfonew}
                    userstatus={siginalready}
                  /&gt;
                )}
              /&gt;
             
            &lt;/Switch&gt;
          &lt;/div&gt;
  
          &lt;div className=&quot;footer&quot;&gt;
            &lt;Footer /&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/Router&gt;
    );
  }
  
  const Home = () =&gt; (
    &lt;div&gt;
      &lt;h1&gt; Home page&lt;/h1&gt;
    &lt;/div&gt;
  );
  
  export default App;
  </code></pre>
  <p>The below is the snippet of code from Child component</p>
  <pre><code>function Signin({ userinfo, userstatus }) {
  return (
      &lt;div&gt;
        {userstatus ? (
          &lt;Useraccount newuserinfo={userinfo} updateduserstatus={userstatus} /&gt;
        ) : (
          &lt;SigninOptions  /&gt;
        )}
      &lt;/div&gt;
    );
  
  }
  export default Signin;
  </code></pre>