HarmonyOS RN中使用react-native-view-shot报错

已按照doc进行配置,在使用时调用:

captureRef(view).then((res) => {
  console.info(`captureRef: ${JSON.stringify(res)}`);
});
  • 1.
  • 2.
  • 3.

日志报错:

Possible Unhandled Promise Rejection (id: 0):
Object {
  "message": "componentSnapshot failed, message = 100001",
}
  • 1.
  • 2.
  • 3.
  • 4.
HarmonyOS
2025-01-10 08:10:21
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
shlp

CppComponentInstance.h中的:

protected:
  std::string getIdFromProps(
  facebook::react::SharedViewProps const& props) const {
  if (props->testId != "") {
  return props->testId;
} else if (props->nativeId != "") {
  return props->nativeId;
} else {
  std::ostringstream id;
  id << ShadowNodeT::Name() << "@" << m_tag;
  return id.str();
}
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.

修改为:

protected:
  std::string getIdFromProps(
  facebook::react::SharedViewProps const& props) const {
  std::ostringstream id;
  id << m_tag;
  return id.str();
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
分享
微博
QQ
微信
回复
2025-01-10 12:03:01


相关问题
HarmonyOS react-native-view-shot使用
541浏览 • 1回复 待解决
HarmonyOS react-native-pager-view安装失败
611浏览 • 1回复 待解决
HarmonyOS react-native-svg(CAPI)使用报错
510浏览 • 1回复 待解决
HarmonyOS react-native-device-info使用报错
409浏览 • 1回复 待解决
HarmonyOS RNreact-native-modal是否支持
352浏览 • 1回复 待解决