rufeng008
V2EX  ›  北京

React native AsyncStorage 更简单的用法

  •  1
     
  •   rufeng008 · Apr 5, 2020 · 2964 views
    This topic created in 2248 days ago, the information mentioned may be changed or developed.

    import { RFStorage } from 'react-native-fast-app';

    const RNStorage = { customerId: undefined ,isShow : undefined, userInfo: undefined }

    RFStorage.init(RNStorage,()=> {

    RNStorage.customerId='123456XXX'; // equivalent to AsyncStorage.setItem('customerId')

    RNStorage.isShow = false; // equivalent to AsyncStorage.setItem('customerId')

    RNStorage.userInfo = { name:'rufeng', age:30};

    console.log(RNStorage.customerId); // equivalent to AsyncStorage.getItem('customerId')

    })

    Supplement 1  ·  Jul 4, 2020
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5524 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 96821589 · 37ms · UTC 07:15 · PVG 15:15 · LAX 00:15 · JFK 03:15
    ♥ Do have faith in what you're doing.