Commit 22229e8
fix(playground): move useState/useCallback above early returns to fix React error #310
useState(copied) and useCallback(handleCopy) were declared after the
if (loading) and if (error) early returns, violating the Rules of Hooks.
When the WASM binary was a 404, the component always hit the error branch
so both renders exited with the same hook count. After committing the WASM
binary (#423), the component now successfully transitions loading→ready,
causing React to see 11 hooks instead of 9 on the second render → #310.
Fix: move both hooks above all conditional returns.
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>1 parent 162ac85 commit 22229e8
1 file changed
+9
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
112 | 121 | | |
113 | 122 | | |
114 | 123 | | |
| |||
190 | 199 | | |
191 | 200 | | |
192 | 201 | | |
193 | | - | |
194 | 202 | | |
195 | 203 | | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | 204 | | |
204 | 205 | | |
205 | 206 | | |
| |||
0 commit comments