#react-native-elements
Вопрос:
Я пытаюсь использовать компонент кнопки react native element, но получаю эту ошибку TypeError: неопределенный не является объектом (оценка ‘_this.props.navigation’). Вот мой Signin.js код компонента кнопки
import * as React from "react"; import { Button, colors } from "react-native-elements"; import MaterialCommunityIcons from "react-native-vector-icons/MaterialCommunityIcons"; import Colors from "../constants/Colors"; export default () =gt; { return ( lt;Button buttonStyle={{ width: 90, height:35, padding: 1 }} containerStyle={{ margin: 5 }} disabledStyle={{ borderWidth: 2, borderColor: "#00F" }} disabledTitleStyle={{ color: "#00F" }} linearGradientProps={null} icon={lt;MaterialCommunityIcons name="key" size={18} color={Colors.accentColor} /gt;} iconContainerStyle={{ background: "#000" }} loadingProps={{ animating: true }} loadingStyle={{}} onPress={() =gt; this.props.navigation.navigate('Profile')} raised title="Signin" titleProps={{}} titleStyle={{ marginHorizontal: 5,color:"#fff" }} type="clear" /gt;
); }
Вот где я вызываю компонент кнопки элемента реакции в Topbar.js
import * as React from "react"; import {StyleSheet, View } from "react-native"; import { Text, Header, Icon } from "react-native-elements"; import { SafeAreaProvider } from "react-native-safe-area-context"; import Colors from "../constants/Colors"; import MakeCall from "./MakeCall"; import ComposeEmail from "./ComposeEmail"; import SigninButton from "./SigninButton"; import SignupButton from "./SignupButton"; export default () =gt; { return ( lt;Header backgroundColor="#000000" backgroundImageStyle={{}} barStyle="default" centerComponent={ lt;View style={styles.container}gt; lt;Viewgt; lt;SigninButton /gt; lt;/Viewgt; lt;Viewgt; lt;SignupButton /gt; lt;/Viewgt; lt;/Viewgt; } centerContainerStyle={{ display: "flex", alignItems: "center", justifyContent: "center", }} containerStyle={{ width: "100%" }} leftComponent={lt;MakeCall /gt;} leftContainerStyle={{}} placement="center" rightComponent={lt;ComposeEmail /gt;} rightContainerStyle={{}} statusBarProps={{}} /gt;
); };
стили const = Таблица стилей.создайте({ контейнер: { flex: 1, flexDirection: ‘строка’, элементы выравнивания: ‘центр’, justifyContent: ‘центр’ } })