Skip to content

Commit

Permalink
remove docId copy
Browse files Browse the repository at this point in the history
  • Loading branch information
jchris committed Feb 8, 2025
1 parent f2da443 commit 3051b4a
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/react/useFireproof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,6 @@ export function useFireproof(name: string | Database = "useFireproof", config: C
// Store the original initial doc without _id for resets
const originalInitialDoc = useMemo(() => deepClone({ ...initialDoc }), []);

// We purposely refetch the docId everytime to check if it has changed
const docId = initialDoc._id ?? "";

// We do not want to force consumers to memoize their initial document so we do it for them.
// We use the stringified generator function to ensure that the memoization is stable across renders.
// const initialDoc = useMemo(initialDocFn, [initialDocFn.toString()]);
Expand Down Expand Up @@ -299,7 +296,7 @@ export function useFireproof(name: string | Database = "useFireproof", config: C

// Primary Object API with both new and legacy methods
const apiObject = {
doc: docId ? { _id: docId, ...doc } : ({ ...doc } as DocWithId<T>),
doc: ({ ...doc } as DocWithId<T>),
merge,
replace,
reset,
Expand All @@ -309,7 +306,7 @@ export function useFireproof(name: string | Database = "useFireproof", config: C
};

// Make the object properly iterable
const tuple = [docId ? { _id: docId, ...doc } : { ...doc }, updateDoc, save, remove, reset, refresh];
const tuple = [{ ...doc }, updateDoc, save, remove, reset, refresh];
Object.assign(apiObject, tuple);
Object.defineProperty(apiObject, Symbol.iterator, {
enumerable: false,
Expand Down

0 comments on commit 3051b4a

Please sign in to comment.