Skip to content

Instantly share code, notes, and snippets.

View watadarkstar's full-sized avatar
🏠
Working from home

Adrian Carolli watadarkstar

🏠
Working from home
View GitHub Profile
import { useState, useEffect } from "react";
import { AsyncStorage } from "react-native";
function useAsyncStorage(key, initialValue) {
const [storedValue, setStoredValue] = useState(initialValue);
useEffect(() => {
AsyncStorage.getItem(key)
.then(value => {
if (value === null) return initialValue;