I'm using useHistory for navigate one screen to other .. but here i;m getting issue called TypeError: undefined is not an object (evaluating 'history.push') i dont know what is wrong here..please hlep me thanks in advance
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>