New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-clear-cache-zzly

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-clear-cache-zzly

react-native library for wechat app

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

react-native-clear-cache

react native 清除缓存第三方库 Mou icon1

导出方法

  • getCacheSize - 获取缓存大小
    • @callBack - Function - 回调函数
      • @cacheSize - String - 缓存大小
      • @unit - String - 缓存大小单位(B KB MB G)

  • runClearCache - 清除缓存
    • @callBack - Function - 回调函数

使用实例

import clear from 'react-native-clear-cache';

constructor () {
    super();
    this.state = {
      cacheSize:"",
      unit:"",
    }
    clear.getCacheSize((value,unit)=>{
      this.setState({
        cacheSize:value, //缓存大小
        unit:unit  //缓存单位
      })
    });
    
  }
  
  render() {
    return (
      <View style={{flex: 1,justifyContent: 'center',alignItems: 'center'}}>
        <Text style={{fontSize: 20,textAlign: 'center',margin: 10}}>
          缓存大小{this.state.cacheSize}{this.state.unit}
        </Text>
        <Button title="清除缓存" onPress={this.clearCache.bind(this)}/>
      </View>
    );
  }
  
  clearCache(){

    clear.runClearCache(()=>{

      console.log("清除成功");

    clear.getCacheSize((value,unit)=>{
      this.setState({
        cacheSize:value, //缓存大小
        unit:unit  //缓存单位
      })
    });
      
    });

  }
  
  

使用方法

npm i react-native-clear-cache -save

自动配置

执行此命令

手动配置

android配置
  1. 设置 android/setting.gradle

    ...
    
    include ':reactNativeClearCache'
    project(':reactNativeClearCache').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-clear-cache/android')
    
    
  2. 设置 android/app/build.gradle

    ...
    dependencies {
        ...
        compile project(':reactNativeClearCache')
    }
    
  3. 注册模块 (到 MainApplication.java)

    import com.zzliaoyuan.firefish.react_native_clear_cache.ClearCachePackage;
    
    public class MainApplication extends Application implements ReactApplication {
      ......
    
        @Override
    	protected List<ReactPackage> getPackages() {
      		return Arrays.<ReactPackage>asList(
          			new MainReactPackage(),
          			new new ClearCachePackage()      //<--- 添加
      		);
    	} 
    
      ......
    
    }
    

ios配置

  1. 右键 Libraries 选择Add Files To "项目名" 进入../node_modules/react-native-clear-cache/ios/目录 选择RCTClearCacheModule.xcodeproj 添加

  2. 在项目Build Phases下的Link Binary With Libraries 下 添加libRCTClearCacheModule.a库文件

Keywords

FAQs

Package last updated on 31 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc