github-actions
released this
25 Oct 09:32
·
24 commits
to main
since this release
Patch Changes
-
93d0e76: Added
useStash
React hook. It's heavily inspired by Zustand'suseStore
and accepts a stash, a state selector, an an optional equality function to avoid unnecessary re-render cycles when returning unstable values.Also updated
getRecord
andgetRecords
to each take either astash
orstate
object for more ergonomic use withuseStash
.import { useStash } from "@latticexyz/stash/react"; import { getRecord } from "@latticexyz/stash"; import config from "../mud.config"; const tables = config.namespaces.app.tables; export function PlayerName({ playerId }) { const record = useStash(stash, (state) => getRecord({ state, table: tables.Player, key: { playerId } })); ... }
import isEqual from "fast-deep-equal"; import { useStash } from "@latticexyz/stash/react"; import { getRecords } from "@latticexyz/stash"; import config from "../mud.config"; export function PlayerNames() { const record = useStash(stash, (state) => getRecords({ state, table: tables.Player }), { isEqual }); ... }
- @latticexyz/[email protected]
- @latticexyz/[email protected]
- @latticexyz/[email protected]
- @latticexyz/[email protected]
- @latticexyz/[email protected]