React native 如何使用功能组件导航到其他组件

React native 如何使用功能组件导航到其他组件,react-native,react-router,React Native,React Router,我正在使用useHistory将一个屏幕导航到另一个屏幕。。但我在这里;我收到的问题称为TypeError:undefined不是一个对象(评估'history.push')我不知道这里出了什么问题..请提前通知我谢谢 import { useHistory } from "react-router-dom"; const history = useHistory(); function intiateVideoCall () { history.push('/Cha

我正在使用
useHistory
将一个屏幕导航到另一个屏幕。。但我在这里;我收到的问题称为
TypeError:undefined不是一个对象(评估'history.push')
我不知道这里出了什么问题..请提前通知我谢谢

import { useHistory } from "react-router-dom";
 const history = useHistory();

function intiateVideoCall ()  {
 history.push('/ChatFunction');
}

const ChatFunction = ({ navigation }) => {
 <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
   <GiftedChat
    messages={messages}
   onSend={messages => handleSendMessage(messages)}
   />
</View>   
}

<TouchableOpacity
    style = {styles.submitButton}
    onPress = {intiateVideoCall}>
  <Text style = {styles.submitButtonText}> Connect </Text>
</TouchableOpacity>
从“react router dom”导入{useHistory};
const history=useHistory();
函数初始化视频调用(){
history.push('/ChatFunction');
}
常量ChatFunction=({navigation})=>{
handleSendMessage(消息)}
/>
}
连接

您不能在react native上使用react路由器dom。您可以使用react导航或react路由器本机