HarmonyOS react-native-view-shot使用

用的react-native-oh-tpl-react-native-view-shot-3.8.0-0.2.0.tgz这个版本。使用react-native-view-shot库的截图功能报错,无论使用vsRef.current?.capture()或者使用captureRef(vsRef),都报如下错误:

{"message": "componentSnapshot failed, message = undefined"}
HarmonyOS
2024-12-25 10:15:23
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
superinsect

尝试将harmony/react_native_openharmony/src/main/cpp/RNOH/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();
}
}

修改为:

protected:
  std::string getIdFromProps(
  facebook::react::SharedViewProps const& props) const {
  std::ostringstream id;
  id << m_tag;
  return id.str();
}
分享
微博
QQ
微信
回复
2024-12-25 12:21:00
相关问题
HarmonyOS react-native-pager-view安装失败
392浏览 • 1回复 待解决
HarmonyOS react-native-cameraroll的使用问题
148浏览 • 1回复 待解决
HarmonyOS 适配 React native
673浏览 • 1回复 待解决
HarmonyOS 使用react-native中的Image问题
172浏览 • 1回复 待解决
HarmonyOS react-native-svg(CAPI)使用报错
278浏览 • 1回复 待解决
HarmonyOS react-native-device-info使用报错
236浏览 • 1回复 待解决
HarmonyOS 咨询React Native适配情况
437浏览 • 1回复 待解决
HarmonyOS 是否接入React Native框架?
501浏览 • 1回复 待解决