Skip to content

Commit

Permalink
Create silver-nails-explain.md
Browse files Browse the repository at this point in the history
  • Loading branch information
holic authored Nov 1, 2023
1 parent 5bd61cc commit a0f288e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .changeset/silver-nails-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
"@latticexyz/store-sync": minor
---

Added a Zustand storage adapter and corresponding `syncToZustand` method for use in vanilla and React apps. It's used much like the other sync methods, except it returns a bound store and set of typed tables.

```ts
import { syncToZustand } from "@latticexyz/store-sync/zustand";
import config from "contracts/mud.config";

const { tables, useStore, latestBlock$, storedBlockLogs$, waitForTransaction } = await syncToZustand({
config,
...
});

// in vanilla apps
const positions = useStore.getState().getRecords(tables.Position);

// in React apps
const positions = useStore((state) => state.getRecords(tables.Position));
```

This change will be shortly followed by an update to our templates that uses Zustand as the default client data store and sync method.

0 comments on commit a0f288e

Please sign in to comment.