Home > OS >  react native use state returns isLoading as a read only instead of setting is value to false
react native use state returns isLoading as a read only instead of setting is value to false

Time:05-19

how can i change the isLoading state to false i'm trying this and i get the error setIsLoading is read only

 const[isLoading, setIsLoading] = React.useState(true);
  const[userToken, setUserToken] = React.useState(null);

  useEffect(() => {
   setTimeout(() => {
      setIsLoading=(false);
    }, 1000);
  }, []);

CodePudding user response:

you have a typo in setIsLoading=(false);

change to setIsLoading(false)

  • Related