From 7eabd06f7af9748aba842d116f1dcd0ef5635999 Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Mon, 13 Nov 2023 09:14:03 +0000 Subject: [PATCH] docs: add changeset for zustand sync progress (#1931) --- .changeset/tricky-gifts-compare.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .changeset/tricky-gifts-compare.md diff --git a/.changeset/tricky-gifts-compare.md b/.changeset/tricky-gifts-compare.md new file mode 100644 index 0000000000..c4737e7eae --- /dev/null +++ b/.changeset/tricky-gifts-compare.md @@ -0,0 +1,13 @@ +--- +"@latticexyz/store-sync": minor +--- + +Added and populated `syncProgress` key in Zustand store for sync progress, like we do for RECS sync. This will let apps using `syncToZustand` render a loading state while initial client hydration is in progress. + +```tsx +const syncProgress = useStore((state) => state.syncProgress); + +if (syncProgress.step !== SyncStep.LIVE) { + return <>Loading ({Math.floor(syncProgress.percentage)}%); +} +```