Я создаю приложение с помощью простого вызова API для отображения изображений и комментариев. пока все хорошо. на одном из моих компонентов я даю URL-адрес изображения и визуализирую их, и все это нормально, но после того, как я получаю комментарии и setState, компонент не перерисовывает и не показывает комментарии. Кто-нибудь может взглянуть и сказать, что я делаю не так
большое спасибо
import React, { Component } from 'react';
import { ScrollView, View, Text, StyleSheet, Alert } from 'react-native';
import lighthouseStyles from './lighthouse.styles';
import PhotoView from 'react-native-photo-view';
import { FooterTab } from 'native-base';
import Icon from 'react-native-vector-icons/Entypo';
import UserLifeMemoriesManager from '../Manager/UserLifeMemoriesManager';
export default class SingleView extends Component {
constructor(props) {
super(props);
let url = this.props.navigation.getParam('ImageUrl', 'ups not work ');
let id = this.props.navigation.getParam('id', 0);
this.state = {
Imageurl: url,
arrayComments: '',
id: id
};
UserLifeMemoriesManager.getMemoryDetails(this.state.id).then(Details => {
this.setstate = {
arrayComments: Details,
commentsArray: Details.response.data.memory.comments
};
});
}
deleteMemory() {
Alert.alert(
'löschen',
'Erinnerung wirklich löschen?',
[
{
text: 'Cancel',
onPress: () => console.info('Cancel Pressed'),
style: 'cancel'
},
{
text: 'OK',
onPress: () => {
UserLifeMemoriesManager.deleteMemory(this.state.id).then(
response => {
this.props.navigation.goBack();
console.info(response);
}
);
}
}
],
{ cancelable: false }
);
}
WholeComments() {
if (this.state.commentsArray) {
return this.state.commentsArray.map(function(news, i) {
return (
<View key = {i}>
<Text>{news.created}</Text>
<View>
<Text>{news.content}</Text>
</View>
</View>
);
});
}
}
render() {
return (
<ScrollView sytle = {styles.container}>
<PhotoView
source = {{ uri: this.state.Imageurl }}
minimumZoomScale = {1}
maximumZoomScale = {3}
androidScaleType = "fitCenter"
onLoad = {() => console.info('Image loaded!')}
style = {{ width: 420, height: 550 }}
/>
{this.WholeComments()}
<View style = {{ height: 42 }}>
<FooterTab style = {{ backgroundColor: '#dadcce' }}>
<Icon.Button
backgroundColor = "#dadcce"
color = "#000000"
name = "bucket"
size = {30}
marginLeft = {12}
padding = {6}
onPress = {() => {
this.deleteMemory();
}}
/>
</FooterTab>
</View>
</ScrollView>
);
}
}
SingleView.navigationOptions = ({ navigation }) => ({
title: 'SingleView'
});
const styles = StyleSheet.create(lighthouseStyles, {
container: {
justifyContent: 'center',
alignItems: 'center'
}
});



![Безумие обратных вызовов в javascript [JS]](https://i.imgur.com/WsjO6zJb.png)


У вас есть ошибка опечатки, а также функция в строке 20:
this.setstate = {
...
}
и это должно быть:
this.setState({
...
})
Для получения дополнительной информации о функции setState: https://reactjs.org/docs/react-component.html#setstate
bitteschön von Leipzig :)
danke es funktioniert man ist manchmal einfach absolute blind das ist fast etwas peinlich: D vielen Dank von Erfurt (und Teilweise Leipzig) nach Leipzig;)