反应本机使用状态

React Native useState

当我尝试使用 useState 时出现此错误: 组件异常

(0,_reactNative.useState) 不是函数。(在'(0,_reactNative.useState)(false)','(0,reactNative.useState)'中未定义)

来源 var children = Component(props, secondArg);

请帮帮我。我不明白为什么我不能使用 useState:(

这是我的代码: `

import React from 'react';
import {StyleSheet,View,Text, Modal,useState} from 'react-native';
import { createAppContainer,NavigationContainer } from 'react-navigation';
import { createStackNavigator } from 'react-navigation-stack';
import HomeScreen from './android/screens/HomeScreen/index';
import LoginScreen from './android/screens/Login/index'

const AppNavigator = createStackNavigator(
  
  {
    
  Home: {screen: HomeScreen},
  Login: {screen: LoginScreen},
},
{
  initialRouteName:'Login'
}
  
);
const AppContainer= createAppContainer(AppNavigator);
export default function App ()  {
  const [modalVisible, setModalVisible] = useState(false);

    

    return (
      
      <AppContainer/>
      
      
    )
  }

正如 Nicholas 所指出的,从 react 而不是 react-native

导入 useState
import React, {useState} from 'react';
import {StyleSheet,View,Text, Modal} from 'react-native';