-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
components: Add useLatestRef hook #33137
Conversation
Size Change: 0 B Total Size: 1.07 MB ℹ️ View Unchanged
|
I've seen 3 variations of this hook:
|
Thanks so much, Diego! I'll update the tests with your suggested changes now. |
2e8b22d
to
012425e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made some suggestions, but we should collect better (and valid) use cases to use as examples in the JSDocs and tests. I'm having trouble trying to create a simple example. I made this CodeSandbox trying to explain how this useLatestRef
works in case it helps others.
EDIT: Updated the CodeSandbox and it's a bit more simple now, so maybe we can use something like that (debounce) in the tests.
07d5a14
to
5d95615
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good! Thanks @sarayourfriend!
5d95615
to
413764b
Compare
Co-authored-by: Haz <hazdiego@gmail.com>
413764b
to
90f09cd
Compare
Description
I'll be honest, I have no idea how to use this or what it does exactly, or what value it brings us. The examples in the JSDoc are not at all helpful to me. If anyone has any suggestions for how to test this thing please let me know (it's used by TextInput so we need to add it one way or another).
How has this been tested?
I added a unit test, but it honestly just demonstrates the existing behavior. I have no idea what else to test.
Types of changes
New feature.
Checklist:
*.native.js
files for terms that need renaming or removal).