简体   繁体   English

反应原生 - Map 数组 state

[英]React Native - Map array state

I'm trying to map array state to add it into urls in react-native-share我正在尝试将 map 数组 state 添加到react-native-share中的urls
But when I'm trying to share it, it shows Error: uriString但是当我尝试分享它时,它显示Error: uriString
In the docs it should look like this: urls: [image1, image2] .在文档中它应该是这样的: urls: [image1, image2] How can I do it?我该怎么做?

Code:代码:

let shareImage = {
            title: `Shared Job from Group ${groupID}`,
            email: shareEmail,
            message: `Group ID ${groupID} | License Number ${data.LicenseNumber}\nModel: ${data.Manufacturer} ${data.Model} ${data.ProductionYear}\nImages:`,
            urls: [...imagesBase64]
        };
        try {
            const shareResponse = await Share.open(shareImage);
            console.log(JSON.stringify(shareResponse));
        } catch (e) {
            console.log('Error => ', e);
        }

I have fixed this issue.我已经解决了这个问题。
I have generated the imagesBase64 inside an useEffect hook.我在useEffect挂钩中生成了imagesBase64
And whenever useEffect was called, it was adding the same images to the imagesBase64 .每当useEffect时,它都会将相同的图像添加到imagesBase64中。 So to fix it, I'm resetting the imagesBase64 at the start of useEffect .所以要修复它,我在imagesBase64开始时重置useEffect

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM