diff --git a/examples/example-vite-react-sdk/src/useSystemCalls.ts b/examples/example-vite-react-sdk/src/useSystemCalls.ts index a8557a8d..e6657727 100644 --- a/examples/example-vite-react-sdk/src/useSystemCalls.ts +++ b/examples/example-vite-react-sdk/src/useSystemCalls.ts @@ -44,7 +44,19 @@ export const useSystemCalls = () => { // Apply an optimistic update to the state // this uses immer drafts to update the state state.applyOptimisticUpdate(transactionId, (draft) => { - if (draft.entities[entityId]?.models?.dojo_starter?.Moves) { + if (!draft.entities[entityId]) { + const newEntity = { + entityId, + models: { + dojo_starter: { + Moves: { + remaining: remainingMoves, + }, + }, + }, + }; + draft.entities[entityId] = newEntity; + } else if (draft.entities[entityId]?.models?.dojo_starter?.Moves) { draft.entities[entityId].models.dojo_starter.Moves.remaining = remainingMoves; }