Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: useTransition hook works correctly with a function argument. (#2287) #2289

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Roman178
Copy link

Why

#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 of SpringRef.
Then, as stated in the comment, if the ref exists, the update is postponed until the ref's start method is called. By calling the ctrl update method, we simply put another item in the queue. Perhaps I didn’t fully understand it, but I didn’t see calling the start method on an existing ref that flushes the queue.

Calling the ref's start method in useIsomorphicLayoutEffect solves the problem.

image

Checklist

  • Documentation updated
  • Demo added
  • Ready to be merged

Copy link

changeset-bot bot commented Jun 12, 2024

⚠️ No Changeset found

Latest commit: 3b762e4

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

Copy link

vercel bot commented Jun 12, 2024

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

@Roman178
Copy link
Author

Hello @joshuaellis
Just a friendly reminder. I would appreciate it if you would take a moment to review at my PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant