У меня есть приложение RN. Попытка передать поля (в ЗАГОЛОВКЕ) с одной страницы на другую (с этой страницы «Чат» TO = страница «Просмотр профиля». Однако это не работает.
Я выделил это касанием, но не работает.
Я продолжаю получать Error = не могу найти 'first_name'. Так что я не думаю, что он получает информацию INSIDE = render () {.....
Вы можете игнорировать ' состояние "вниз. Просто хотел показать вам макет страницы.
import React, { Component } from "react";
import {
StyleSheet,
View,
Text,
TouchableHighlight,
Dimensions,
Share,
AlertIOS,
Alert,
TouchableOpacity,
Platform,
KeyboardAvoidingView,
KeyboardSpacer,
StatusBar,
DeviceEventEmitter
} from "react-native";
import { LinearGradient } from 'expo-linear-gradient';
import { GiftedChat } from "react-native-gifted-chat";
import { NavigationActions } from "react-navigation";
import moment from "moment";
import * as firebase from "firebase";
import Email from "../modules/email";
import withPreventDoubleClick from "../components/withPreventDoubleClick";
import CircleImage from "../components/circleImage";
import { Entypo } from "@expo/vector-icons";
import {
ActionSheetProvider,
connectActionSheet
} from "@expo/react-native-action-sheet";
import Modal from "react-native-modal";
const { width, height } = Dimensions.get("window");
const TouchableHighlightEx = withPreventDoubleClick(TouchableHighlight);
import { StackNavigator } from "react-navigation";
@connectActionSheet
class App extends React.Component {
render() {
const first_name = this.props.profile.first_name;
const uid = this.props.user.uid;
const user = this.props.user;
const profile = this.props.profile;
const profileId = this.props.profile.uid;
//const uid = this.props.profile.uid;
//const { id, birthday, first_name, work, imageObj, education } = this.props.navigation.state.params;
return (
<View style={styles.container}>
{Platform.OS === "ios" && (
<Entypo
name="dots-three-vertical"
size={25}
style={{ paddingRight: 7, marginTop: 7 }}
color={"#fff"}
onPress={this._onOpenActionSheet}
/>
)}
{Platform.OS !== "ios" && (
<Entypo
name="dots-three-vertical"
size={25}
style={{ paddingRight: 7, marginTop: 15 }}
color={"#fff"}
onPress={() => this._showModal()}
/>
)}
</View>
);
}
export default class Chat extends Component {
//static navigationOptions = {
static navigationOptions = ({ navigation }) => ({
render() {
const first_name = this.props.profile.first_name;
const uid = this.props.user.uid;
const user = this.props.user;
const profile = this.props.profile;
},
headerTitle: (
<TouchableHighlightEx
underlayColor="transparent"
onPress={() =>
navigation.navigate("ProfileView", {
first_name,
birthday,
id,
uid,
date1,
date2,
date3,
profileUid,
profile: rowData,
user: this.props.navigation.state.params.user
})
}
>
<View
style={{
flexDirection: "row",
alignItems: "center",
justifyContent: "center"
}}
>
<CircleImage
size={30}
uri={navigation.state.params.profile.imageObj.img_0}
style={{
width: 32,
height: 32,
resizeMode: "contain",
alignSelf: "center"
}}
/>
<Text style={{ color: "#fff", fontSize: 17, marginLeft: 5 }}>
{navigation.state.params.first_name}
</Text>
</View>
</TouchableHighlightEx>
),
title: navigation.state.params.first_name,
headerTintColor: "#fff",
headerBackTitle: null,
headerRight: (
<ActionSheetProvider>
<App
method={navigation.state.params._showModal}
goBack={navigation.state.params._goBack}
details={navigation.state.params.first_name}
profileId={navigation.state.params.profileUid}
uid={navigation.state.params.user.uid}
user={navigation.state.params.user}
profile={navigation.state.params.profile}
/>
</ActionSheetProvider>
),
headerStyle: {
backgroundColor: "#ff0000",
shadowOpacity: 0,
// iOS
borderBottomWidth: 0,
// Android
elevation: 0
},
});
state = {
messages: [],
user: this.props.navigation.state.params.user,
profile: this.props.navigation.state.params.profile,
modalShow: false,
blockUnblockText: "Block User",
datePlan: null,
isDateLoaded: false,
canLoadEarlier: true,
loadingEarlier: false
};
currentMessage = 20;
messagePerPage = 20;