From 28d3de9b54b77151552afdad53988efa42d28b86 Mon Sep 17 00:00:00 2001 From: ymekuria Date: Sun, 22 Sep 2024 22:01:40 -0700 Subject: [PATCH] feat(index.page.tsx): add state for zkappWorkerClient to manage web worker client instance --- .../zkapps/04-zkapp-browser-ui/ui/src/pages/index.page.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/zkapps/04-zkapp-browser-ui/ui/src/pages/index.page.tsx b/examples/zkapps/04-zkapp-browser-ui/ui/src/pages/index.page.tsx index 60ffe60d6..955ef0530 100644 --- a/examples/zkapps/04-zkapp-browser-ui/ui/src/pages/index.page.tsx +++ b/examples/zkapps/04-zkapp-browser-ui/ui/src/pages/index.page.tsx @@ -19,7 +19,8 @@ export default function Home() { zkappPublicKeyBase58: '', creatingTransaction: false, }); - + + const [zkappWorkerClient, setZkappWorkerClient] = useState(null); const [displayText, setDisplayText] = useState(''); const [transactionlink, setTransactionLink] = useState(''); @@ -33,6 +34,8 @@ export default function Home() { setDisplayText('Loading web worker...'); console.log('Loading web worker...'); const zkappWorkerClient = new ZkappWorkerClient(); + setZkappWorkerClient(zkappWorkerClient); + await new Promise((resolve) => setTimeout(resolve, 5000)); setDisplayText('Done loading web worker'); @@ -84,7 +87,6 @@ export default function Home() { setState({ ...state, - zkappWorkerClient, hasWallet: true, hasBeenSetup: true, publicKeyBase58,