var array=this.state.filter_photos.map(x => {
var container={}
if(x.uri===this.state.photo_object.picture){
x.new_uri=this.state.imageURI;
}
container=x;
console.log('tableau30 ',container)
return container;
});
console.log('tablau4',array) // can't read this
this.setState({filter_photos :array}) // can't setstate
**这是我的全部代码**
构造函数(道具){ 超级(道具);
this.state = { filter_photos: [], } captureScreenFunction () { this.refs.viewshot.capture().then(uri => { this.setState({ imageURI: uri }), CameraRoll.saveToCameraRoll(uri, "photo"); this.state.photo_object.new_uri=this.state.imageURI; this.setState(prev => ({ filter_photos: prev.filter_photos.map(photo => { if (photo.uri === prev.photo_object.picture) { photo.new_uri = prev.imageURI; } console.log('tableau30 ',photo) return photo; }) })); console.log('tablau4',this.state.filter_photos) // this console doesn't show }); }
render(){
this.state.filter_photos = this.props.filter_photos; // initilisation
return()
****当我在控制台上显示this.state.filter_photos时,它不会显示* *我在渲染中启动了filter_photos ****