0
votes

I am new to react native. I have created a screen. in which I have added digital signature. when I dragged signature then I am saving its image in State. and then I am showing this state image on screen. but I am getting error like this = warning: Failed prop type: Invalid prop source supplied to Image. please help. here is code

const[Image1, setImage1]= useState(null);

    const Image1 = result.pathName;
    console.log("Response = "+Image1);
    setImage1({Image1: Image1})

 <Image
                source={{uri : Image1}}
                style={{
                 width: '100%',
                 height: 200,
                 resizeMode: 'contain',
                 }} />

1

1 Answers

0
votes

useState variable first word must be lower case

you cant use the same variable name, if you're using network image then your image component should like this,

const[image, setImage]= useState(null);
const [imagePath,setImagePath ] = useState(result.pathName);
console.log("Response = "+imagePath);
setImage(imagePath)

 <Image 
source={{uri : image}}
style={{
width: '100%',
height: 200,
resizeMode: 'contain',
 }} 
/>

else if you using local image then your image component like this,

<Image 
source={require(image)}
style={{
width: '100%',
height: 200,
resizeMode: 'contain',
 }} 
/>