In this code when you click on button a screenshot should be taken and screenshot should be shown by updating useState, but i get this error: json.stringify cannot serialize cyclic structures how can i solve this?
let [ImageURI, setImageURI,]=useState(<Image source={{uri:'http://website.com/wp-content/uploads/image.jpg'}}/>);
Here the function is that we use for taking screenshot and updating useState:
const captureScreenFunction=()=>{
captureScreen({
format: "jpg",
quality: 0.8
}).then(
uri => setImageURI(ImageURI=uri),
error => console.error("Oops, snapshot failed", error)
);
}
And here what is returns:
return (
<Fragment>
<Button
title='capture screen'
onPress={captureScreenFunction}
>
</Button>
<Image
source={{uri:ImageURI}}
style={{width:300, height:200, resizeMode:'contain', marginTop:15}}
></Image>
</Fragment>
)