2015-10-21 35 views

回答

0

可以使用助焊劑店,異步存儲來存儲在存儲中的當前狀態,並重新路由基於商店

可以使用componentWillMount渲染視圖之前設置的狀態混合。例如:

componentWillMount() { 
    LocalStorage.bootstrap(() => this.setState({bootstrapped: true})); 
}, 

例如你可以參考https://github.com/brentvatne/flux-util/blob/master/lib/flux-util.js

0

您可以使用與react-native捆綁在一起的AsyncStorage。它創建鍵值對

AsyncStorage.setItem("key", "value").done() // both key and value have to be strings AsyncStorage.getItem("key").then((value) =>{}).done()

如果你想要做的事,你或許應該使用react-native-keychain這樣就可以像自動登錄您可以檢查更多的選擇 https://facebook.github.io/react-native/docs/asyncstorage.html#content

+0

請注意,這是未加密的,不應該用於敏感用戶數據 – KrauseFx

5

文檔以更安全的方式將用戶憑證存儲在設備上的鑰匙串中。

如果您正在尋找存儲特定應用程序狀態或者你可以使用react-native-simple-store提供圍繞AsyncStorage一個非常簡單的包裝和負責樣板JSON.stringify/JSON.parse的,你需要做其他非敏感數據對象和數組。

希望有幫助!

相關問題