Commit 02efe83
committed
fix(useViewportEffect): support changing recalculateLayoutBeforeUpdate in combination with deferUpdateUntilIdle
When recalculateLayoutBeforeUpdate is used with a dynamic value in a
function, e.g. useRect, the function is not reassninged to the listener.
This can especially become an issue with deferUpdateUntilIdle.
In the example of useRect, the deferred function will be called with the
old element (which might be null) and the update which is triggered
afterwards containing the new function is not respected any longer.
Afterwards the dependency is not changing any longer, therefore the
state stays undefined.
Using a dynamic function that calls the latest function independent of
when it was registered fixes the issue.
Closes #161 parent 725caea commit 02efe83
1 file changed
+4
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
67 | 70 | | |
68 | 71 | | |
69 | 72 | | |
| |||
0 commit comments