-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |