0

I'm creating this Instagram Clone, I have the image local url and I want to show it to the user before he posts it.

I tried to crate a state var, tried to require but nothing works

<Image source={this.state.img_url} />

This is what I need, thanks for helping me!

2 Answers2

1

Here is the solution I found

    render(){
        //Getting image from Camera Screen
        var imgSource = this.state.img_url;
        return(
            <View>
                <Image
                    source={{ uri: imgSource }}
                    style={{width: 400, height: 400}} 
                />
            </View>
        );
    }
1

For showing image in react-native, you need to provide an object which contains uri property. Below code will set a responsive image

<View>
    <Image source={{ uri: 'image-path' }} style={{ height: 300, flex: 1, width: null }}>
</View>
ashish pandey
  • 985
  • 7
  • 14