Skip to content

react-native-hooks/async-storage

Repository files navigation

@rnhooks/async-storage Build Status Maintainability module formats: umd, cjs, esm

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

Questions

Feel free to contact me or create an issue

About

React Native hook for Async Storage

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published