Membrane React - v0.29.2
    Preparing search index...

    Type Alias MutatorCallback<Data>

    MutatorCallback: (
        currentData?: Data,
    ) => Promise<undefined | Data> | undefined | Data

    Callback function type for mutator operations.

    This function receives the current cached data and can return new data to update the cache. It can be synchronous or asynchronous, and can return undefined to indicate no change should be made.

    Type Parameters

    • Data = any

      The type of the cached data

    Type Declaration

      • (currentData?: Data): Promise<undefined | Data> | undefined | Data
      • Parameters

        • OptionalcurrentData: Data

          The current data in the cache (may be undefined)

        Returns Promise<undefined | Data> | undefined | Data

        New data to set, undefined for no change, or a Promise resolving to either

    // Increment a counter
    mutate(key, (current: number = 0) => current + 1)

    // Async update
    mutate(key, async (current) => {
    const updated = await updateData(current)
    return updated
    })