Skip to main content

Function: useUpdateSave()

useUpdateSave(): (slot, changes) => Promise<SaveResult>

Defined in: packages/core/src/saves/hooks/useUpdateSave.ts:28

React hook that provides a function to edit a save's label and metadata without recapturing the game state.

Returns

Function that accepts a slot and the fields to change

(slot, changes): Promise<SaveResult>

Parameters

slot

string | number

changes

SaveUpdate

Returns

Promise<SaveResult>

Remarks

The save's timestamp is left alone, so a renamed save keeps its place in a list ordered by recency.

Example

const updateSave = useUpdateSave();
const handleRename = async (slot: number, title: string) => {
const result = await updateSave(slot, { title });
if (!result.success) {
console.error('Rename failed:', result.error);
}
};