提问人:GoGuy 提问时间:10/30/2023 更新时间:10/30/2023 访问量:17
“Property”不是 BranchUniversalObject 支持的属性 - React Native 在IOS上使用效果警告
"Property" is not a supported property for BranchUniversalObject - React Native useEffect Warnings on IOS
问:
我正在使用功能组件构建一个 React Native 应用程序,并尝试实现 useEffect 来为 QR 码生成器生成 URL 和字符串。代码运行良好,但在 IOS 上,React Native 似乎没有理由抛出多个警告,所有人都说“Property”版本不是 BranchUniversalObject 支持的属性......当它们是受支持的属性时。
谁能帮我理解为什么当我实现useEffect时它可能会抛出这些警告?有没有更好的方法来实现此代码,因为useEffect似乎会导致警告。
终端错误日志:
WARN "generateShortUrl" is not a supported property for BranchUniversalObject.
WARN "_newIdent" is not a supported property for BranchUniversalObject.
WARN "registerView" is not a supported property for BranchUniversalObject.
WARN "logEvent" is not a supported property for BranchUniversalObject.
WARN "release" is not a supported property for BranchUniversalObject.
WARN "listOnSpotlight" is not a supported property for BranchUniversalObject.
WARN "ident" is not a supported property for BranchUniversalObject.
WARN "showShareSheet" is not a supported property for BranchUniversalObject.
WARN "_tryFunction" is not a supported property for BranchUniversalObject.
WARN "userCompletedAction" is not a supported property for BranchUniversalObject.
BranchUniversalObject 接口
interface BranchUniversalObject {
ident: string;
showShareSheet: (
shareOptions?: BranchShareSheetOptions,
linkProperties?: BranchLinkProperties,
controlParams?: BranchLinkControlParams
) => Promise<BranchShareSuccess | BranchShareFailure>;
generateShortUrl: (
linkProperties?: BranchLinkProperties,
controlParams?: BranchLinkControlParams
) => Promise<{ url: string }>;
logEvent: (eventName: string, params?: BranchEventParams) => Promise<null>;
release: () => void;
}
QR码生成
// Creates a QR Code with Branch link parameters
static createQRCode = async () => {
let qrCodeSettings = {
width: 800,
codeColor: '#6a09d9',
backgroundColor: '#fac3c3',
centerLogo: 'https://i.snipboard.io/5PW62T.jpg',
margin: 1,
imageFormat: 'PNG',
};
let buo = await this.createContentReference();
let linkProperties = await this.createLinkProperties();
let controlParams = await this.createControlParameters();
try {
let result = await branch.getBranchQRCode(
qrCodeSettings,
buo,
linkProperties,
controlParams,
);
return Promise.resolve('data:image/png;base64,' + result);
} catch (err) {
return Promise.reject('BranchWrapper QR Code Err: ' + err);
}
};
useEffect 利用率:
// Sets the QR Code string on Page Load
const [qrCodeString, setQRCodeString] = useState('');
useEffect(() => {
async function getQRCodeString() {
const qrCode = await BranchUtils.createQRCode();
setQRCodeString(qrCode);
}
getQRCodeString();
});
图像:
<Image
style={styles.qrCodeImage}
source={{
uri: qrCodeString,
}}
/>
答: 暂无答案
评论