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

    Type Alias MutatorOptions<Data, MutationData>

    Options for configuring mutator behavior.

    These options control how the mutation affects the cache, revalidation, and error handling behavior.

    type MutatorOptions<Data = any, MutationData = Data> = {
        revalidate?: boolean | ((data: Data, key: Arguments) => boolean);
        populateCache?:
            | boolean
            | ((result: MutationData, currentData: Data | undefined) => Data);
        optimisticData?:
            | Data
            | (
                (
                    currentData: Data | undefined,
                    displayedData: Data | undefined,
                ) => Data
            );
        rollbackOnError?: boolean | ((error: unknown) => boolean);
        throwOnError?: boolean;
    }

    Type Parameters

    • Data = any

      The type of the data related to the key

    • MutationData = Data

      The type of the data returned by the mutator

    Index

    Properties

    revalidate?: boolean | ((data: Data, key: Arguments) => boolean)

    Whether to revalidate the cache after mutation.

    Can be a boolean or a function that receives the new data and key to determine whether revalidation should occur.

    true
    
    populateCache?:
        | boolean
        | ((result: MutationData, currentData: Data | undefined) => Data)

    Whether and how to populate the cache with mutation results.

    • false: Don't update the cache
    • true: Update cache with mutation result directly
    • Function: Transform mutation result before caching
    true
    
    optimisticData?:
        | Data
        | (
            (
                currentData: Data | undefined,
                displayedData: Data | undefined,
            ) => Data
        )

    Optimistic data to show immediately while mutation is pending.

    Can be the data directly or a function that computes it based on current and displayed data. Useful for immediate UI feedback.

    undefined
    
    rollbackOnError?: boolean | ((error: unknown) => boolean)

    Whether to rollback optimistic updates on error.

    Can be a boolean or a function that receives the error to determine whether rollback should occur.

    true
    
    throwOnError?: boolean

    Whether to throw errors instead of returning them in the error field.

    When true, errors will be thrown and can be caught with try/catch. When false, errors are returned in the response object.

    false