React Native Storage - v2.0.0
    Preparing search index...

    One typed value in a Storage. Create it with storage.item(name, options).

    subscribe and getSnapshot follow the contract of React's useSyncExternalStore, which is what useStorageItem builds on.

    Type Parameters

    • T
    Index
    name: string
    key: string

    The key in the driver, with the namespace.

    defaultValue: T
    • Reads the value. Unreadable data gives the default value and is reported to onError.

      Returns Promise<T>

    • Validates, encodes and saves a value. Pass a function to update from the current value. Rejects with VALIDATION_FAILED, UNSERIALIZABLE, VALUE_TOO_LARGE, INVALID_OPTION or DRIVER_ERROR; nothing is written then.

      Parameters

      Returns Promise<void>

    • Deletes the stored value; reads return the default value afterwards.

      Returns Promise<void>

    • Reads the value into the cache, so getSnapshot stops reporting loading.

      Returns Promise<void>

    • Calls listener after every change. For useSyncExternalStore.

      Parameters

      • listener: () => void

      Returns () => void