Open Roman178 opened 3 weeks ago
Latest commit: 3b762e4f094ee0dbb117352fded711de5b8241c4
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Updated (UTC) |
---|---|---|---|
react-spring | ✅ Ready (Inspect) | Visit Preview | Jun 12, 2024 1:53pm |
Why
https://github.com/pmndrs/react-spring/issues/2287. The useTransition hook doesn't work correctly if we pass a function as an argument.
What
If we pass a function to the hook, a
ref
variable will be created, an instance ofSpringRef
. Then, as stated in the comment, if theref
exists, the update is postponed until theref
'sstart
method is called. By calling the ctrlupdate
method, we simply put another item in the queue. Perhaps I didn’t fully understand it, but I didn’t see calling thestart
method on an existingref
that flushes the queue.Calling the
ref
'sstart
method in useIsomorphicLayoutEffect solves the problem.Checklist