React Native hook for AsyncStorage
import useAsyncStorage from '@rnhooks/async-storage';
function App() {
const [storageItem, updateStorageItem, clearStorageItem] = useAsyncStorage(
key,
);
return (
<View style={styles.container}>
<Text style={styles.type}>{`Storage Value: ${storageItem}`}</Text>
<Button
title="Update Item"
onPress={() => updateStorageItem('Test String')}
/>
<Button title="Clear Item" onPress={() => clearStorageItem()} />
</View>
);
}
Name | Type | Default | Description |
---|---|---|---|
key | String | null |
Async Storage Key |
Name | Type | Default | Description |
---|---|---|---|
storageItem | String | null |
Async Storage Item |
updateStorageItem | function | () => {} |
Async Storage updater method |
clearStorageItem | function | () => {} |
Async Storage clear item method |
- @pritishvaidya The main author.
Feel free to contact me or create an issue