Error while updating property 'src' of a view managed by: RCTImageView (Android)

See original GitHub issue

Hello! I receive an error:

Error while updating property 'src' of a view managed by: RCTImageView
updateViewProp
    ViewManagersPropertyCache.java:90
setProperty
    ViewManagerPropertyUpdater.java:123
updateProps
    ViewManagerPropertyUpdater.java:42
updateProperties
    ViewManager.java:36
createView
    NativeViewHierarchyManager.java:227
execute
    UIViewOperationQueue.java:149
dispatchPendingNonBatchedOperations
    UIViewOperationQueue.java:892
doFrameGuarded
    UIViewOperationQueue.java:865
doFrame
    GuardedChoreographerFrameCallback.java:32
doFrame
    ReactChoreographer.java:131
run
    Choreographer.java:869
doCallbacks
    Choreographer.java:683
doFrame
    Choreographer.java:616
run
    Choreographer.java:857
handleCallback
    Handler.java:751
dispatchMessage
    Handler.java:95
loop
    Looper.java:154
main
    ActivityThread.java:6077
invoke
    Method.java:-2
run
    ZygoteInit.java:865
main
    ZygoteInit.java:755

And here is part of my code:

import React, { Component } from 'react';

import {
    StyleSheet,
    Text,
    View,
    TouchableOpacity,
    Platform,
    ScrollView,
    Image,
} from 'react-native';

let ImagePicker = require('react-native-image-picker');

let options = {
    title: 'Добавьте фото',
    storageOptions: {
        skipBackup: true,
        path: 'images'
    },
    cancelButtonTitle: 'Отмена',
    takePhotoButtonTitle: 'Сфотографировать',
    chooseFromLibraryButtonTitle: 'Выбрать из галереи',

};

export default class PassportDataSimple extends Component {

    static navigationOptions = {
        header: { visible: false },
    };


    constructor(props){
        super(props);
        this.state = {
            passportPhoto: null
        }
    }
    _pickPhoto(){
        ImagePicker.showImagePicker(options, (response) => {
            console.log('Response = ', response);

            if (response.didCancel) {
                console.log('User cancelled image picker');
            }
            else if (response.error) {
                console.log('ImagePicker Error: ', response.error);
            }
            else if (response.customButton) {
                console.log('User tapped custom button: ', response.customButton);
            }
            else {
                // You can also display the image using data:
                // let source = { uri: 'data:image/jpeg;base64,' + response.data };
                this.setState({
                    passportPhoto: { uri: response }
                });
            }
        });
    }

    render() {
        return (
            <View style={styles.container}>             
                <ScrollView style={{ flex:1}} showsVerticalScrollIndicator={false}>
                    <View style={{justifyContent: 'flex-start',alignItems: 'flex-start',}}>
                      <View style={{flex:0,alignSelf: 'stretch', justifyContent: 'flex-start', alignItems: 'flex-start', 
                                 backgroundColor: 'white', marginHorizontal: 16}}>
                            
                                        <Image  source={this.state.passportPhoto}
                                    style={{flex:1,alignSelf: 'stretch', justifyContent: 'center', alignItems: 'flex-start', 
                                          marginHorizontal:16}}
                                />

                            <TouchableOpacity
                                onPress={(e) => this._pickPhoto()}
                                style={{flex:0,alignSelf: 'stretch', justifyContent: 'center', alignItems: 'flex-start', backgroundColor: 'white', marginVertical:16}}>
                                <Text style={{color: '#c98d41', fontSize: 14}}>ДОБАВИТЬ ФОТО</Text>
                            </TouchableOpacity>
                           
                        </View>
                    </View>
                </ScrollView>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        flex:1,
        backgroundColor: 'white'
    }
});

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7

github_iconTop GitHub Comments

8reactions
Nygma297commented, Apr 11, 2017

Try using response.uri instead of just response

here


   ImagePicker.showImagePicker(options, (response) => {

               . . . 

                // You can also display the image using data:
                // let source = { uri: 'data:image/jpeg;base64,' + response.data };
                this.setState({
                    passportPhoto: { uri: response } // make it response.uri
                });
            }
        });

4reactions
AlMel3000commented, Apr 11, 2017

So method is:

 _pickPhoto(){
        ImagePicker.showImagePicker(options, (response) => {
            console.log('Response = ', response);

            if (response.didCancel) {
                console.log('User cancelled image picker');
            }
            else if (response.error) {
                console.log('ImagePicker Error: ', response.error);
            }
            else if (response.customButton) {
                console.log('User tapped custom button: ', response.customButton);
            }
            else {

                this.setState({
                    passportPhoto: {uri: response.uri, isStatic: true}
                });
            }
        });
    }

Element is:

<Image  source={{uri: this.state.passportPhoto}}
                                    style={{flex:1,alignSelf: 'stretch', justifyContent: 'center', alignItems: 'flex-start', marginHorizontal:24}}  />

But here is old mistake:


Error while updating property 'src' of a view managed by: RCTImageView
updateViewProp
    ViewManagersPropertyCache.java:90
setProperty
    ViewManagerPropertyUpdater.java:123
updateProps
    ViewManagerPropertyUpdater.java:42
updateProperties
    ViewManager.java:36
createView
    NativeViewHierarchyManager.java:227
execute
    UIViewOperationQueue.java:149
run
    UIViewOperationQueue.java:778
flushPendingBatches
    UIViewOperationQueue.java:831
access$1500
    UIViewOperationQueue.java:45
doFrameGuarded
    UIViewOperationQueue.java:870
doFrame
    GuardedChoreographerFrameCallback.java:32
doFrame
    ReactChoreographer.java:131
run
    Choreographer.java:869
doCallbacks
    Choreographer.java:683
doFrame
    Choreographer.java:616
run
    Choreographer.java:857
handleCallback
    Handler.java:751
dispatchMessage
    Handler.java:95
loop
    Looper.java:154
main
    ActivityThread.java:6077
invoke
    Method.java:-2
run
    ZygoteInit.java:865
main
    ZygoteInit.java:755



Read more comments on GitHub >

github_iconTop Results From Across the Web

I get this error "Error while updating property 'src' of a view ...
Try this. Update source in Animated.Image to image.ImageUrl instead of just "image" <Animated.Image key={'image-${index}'} ...
Read more >
react-native-image-picker' Error while updating property 'src' of ...
Coding example for the question 'react-native-image-picker' Error while updating property 'src' of a view managed by: RCTImageView-React Native.
Read more >
Error while updating property 'src' of a view managed by
Issue Description. when I tried to upload image using react-native -gifted-chat, I got red red screen saying that "Error while updating ...
Read more >
react-native-fast-image Error while updating property 'source ...
react-native-fast-image Error while updating property 'source' of a view managed by: FastImageView. Android Feb 22, 2020 Viewed 2K Comments 0.
Read more >
Image value for uri cannot be cast from double to string - Reddit
@flow import React from 'react' import { Text, View, Image, ... Edit: on second thoughts the error is saying property src instead of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found