Commit c659dc9
Fix useTable isReady reverting to false after first row event (#4580)
Fixes #4559.
## Bug
The `subscribe` callback passed to `useSyncExternalStore` captures
`computeSnapshot` in its closure but did not list it as a dependency.
When `subscribeApplied` flips to `true`:
1. `computeSnapshot` is recreated with `subscribeApplied = true`
2. But `subscribe` still holds the **stale** closure that captured
`subscribeApplied = false`
3. On the next row event, the stale `computeSnapshot` writes `[rows,
false]` into `lastSnapshotRef`
4. `isReady` drops to `false` permanently
## Fix
Add `computeSnapshot` to the `subscribe` dependency array so event
handlers always use the current snapshot function.
Note: PR #4499 previously fixed a related issue where the cached
snapshot was stale after `subscribeApplied` changed. This fix addresses
the remaining case where the `subscribe` closure itself was stale.
---------
Signed-off-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>1 parent 61be6e6 commit c659dc9
1 file changed
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
| 108 | + | |
107 | 109 | | |
108 | 110 | | |
109 | 111 | | |
| |||
205 | 207 | | |
206 | 208 | | |
207 | 209 | | |
| 210 | + | |
| 211 | + | |
208 | 212 | | |
209 | 213 | | |
210 | 214 | | |
211 | 215 | | |
212 | 216 | | |
| 217 | + | |
213 | 218 | | |
214 | 219 | | |
215 | 220 | | |
| |||
0 commit comments