@rnhooks/async-storage
v0.0.2
Published
React Native hook for AsyncStorage
Downloads
98
Readme
@rnhooks/async-storage
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>
);
}
Input
| Name | Type | Default | Description |
| :------------ |---------------:| :---------------| :-----|
| key | String | null
| Async Storage Key |
Output
| Name | Type | Default | Description |
| :------------ |---------------:| :---------------| :-----|
| storageItem | String | null
| Async Storage Item |
| updateStorageItem | function | () => {}
| Async Storage updater method |
| clearStorageItem | function | () => {}
| Async Storage clear item method |
Contribution
- @pritishvaidya The main author.
Questions
Feel free to contact me or create an issue