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"}
阅读 423
1 个回答

尝试将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();
}