removeImageForTag()未实现(React Native)

时间:2017-11-24 15:24:33

标签: reactjs react-native expo

我收到此removeImageForTag()错误

enter image description here

这是我的源代码

ImageEditor.cropImage(
  this.state.image,
  imageData,
  (successURI) => {
    ImageStore.getBase64ForTag(successURI,
      (base64Data) => {
        console.log(base64Data);
      },
      (failure) => {console.log('failed to load')});
    console.log(successURI);
    ImageStore.removeImageForTag(successURI) <<<
  },
  (error) => { console.log('ERROR: ', error)}
)

我猜它的包装错误,但版本号似乎没问题。

react-native-cli: 2.0.1
react-native: 0.48.4

"expo": "^21.0.0",

removeImageForTag doc在这里:https://facebook.github.io/react-native/releases/0.39/docs/imagestore.html#removeimagefortag

2 个答案:

答案 0 :(得分:2)

我为此感到疯狂。.removeImageForTag不能为Android定义吗?

然后我意识到,在Android中,URL(在您的示例中为成功URI)是应用程序缓存的路径(例如:file:///data/user/0/com.your.project/cache/ReactNative_cropped_image_-1677432906.jpg)。

您可以使用任何文件系统库(例如rn-fetch-blobreact-native-fsExpo.FileSystem.deleteAsync(如果使用expo)删除图像)

答案 1 :(得分:1)

removeImageForTag方法默认情况下仅在iOS上可用。要添加对Android的支持,您可以使用以下模块:https://github.com/seancunningham/react-native-image-store-ext