create-sia-app 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-sia-app",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "create-sia-app": "./dist/index.js"
@@ -1,4 +1,4 @@
1
- import { useEffect, useState } from 'react'
1
+ import { useEffect, useRef, useState } from 'react'
2
2
  import type { Builder } from '../../lib/sdk'
3
3
  import { useAuthStore } from '../../stores/auth'
4
4
  import { CopyButton } from '../CopyButton'
@@ -13,9 +13,13 @@ export function ApproveScreen({
13
13
  const [polling, setPolling] = useState(true)
14
14
  const [pollError, setPollError] = useState(false)
15
15
  const [manualChecking, setManualChecking] = useState(false)
16
+ const pollStarted = useRef(false)
16
17
 
17
18
  useEffect(() => {
18
- let cancelled = false
19
+ // Guard against React strict mode double-mount — waitForApproval()
20
+ // consumes the builder's state and cannot be called twice.
21
+ if (pollStarted.current) return
22
+ pollStarted.current = true
19
23
 
20
24
  async function poll() {
21
25
  const b = builder.current
@@ -23,21 +27,14 @@ export function ApproveScreen({
23
27
 
24
28
  try {
25
29
  await b.waitForApproval()
26
- if (!cancelled) {
27
- setStep('recovery')
28
- }
30
+ setStep('recovery')
29
31
  } catch {
30
- if (!cancelled) {
31
- setPolling(false)
32
- setPollError(true)
33
- }
32
+ setPolling(false)
33
+ setPollError(true)
34
34
  }
35
35
  }
36
36
 
37
37
  poll()
38
- return () => {
39
- cancelled = true
40
- }
41
38
  }, [builder, setStep])
42
39
 
43
40
  async function handleManualCheck() {