react native use state returns isLoading as a read only 而不是设置 is value to false

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

如何将 isLoading 状态更改为 false 我正在尝试此操作,但收到错误 setIsLoading is read only

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

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

你有一个错字 setIsLoading=(false);

改为setIsLoading(false)