Hook state is undefined SDK 40

Please provide the following:

  1. SDK Version: 49
  2. Platforms(Android/iOS/web/all): Web, Android and iOS

Hook state is undefined.

export default function NoInternet() {
  const { network, updateNetwork } = useState(false);

  useEffect(() => {
    
    updateNetwork(true); //This method is undefined
    console.log(network); //This return undefined
    
  }, []);

  return <View>
      <Text>{network? "Internet is working": "Please check your internet."}</Text>
  </View>

}

Hi @geek_lekan,

According to the documentation your code should look like:

const [ network, updateNetwork ] = useState(false);
1 Like

ARRRGH, I can’t believe I missed that. Thanks @cornel.raiu

2 Likes