-
Notifications
You must be signed in to change notification settings - Fork 68
CPLAT-8038 Implement/Expose useCallback Hook #233
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
Conversation
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.
+10
I went in circles on this in my head and DID NOT understand what useCallback
did it took me FAR too long lol i should have just looked at your tests...
lib/hooks.dart
Outdated
/// Note there are two rules for using Hooks (<https://reactjs.org/docs/hooks-rules.html>): | ||
/// | ||
/// * Only call Hooks at the top level. | ||
/// * Only call Hooks from inside a [DartFunctionComponent]. |
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.
#nit, we can do this later and not a big deal, and i only just realized this after reviewing all these, that maybe this should be formatted like this:
/// > __Note:__ there are two [rules for using Hooks](https://reactjs.org/docs/hooks-rules.html):
/// >
/// > * Only call Hooks at the top level.
/// > * Only call Hooks from inside a [DartFunctionComponent].
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.
I updated this in a couple places and I'll make sure the rest are updated in the overall hooks branch
react_test_utils.Simulate.click(incrementDeltaButtonRef); | ||
}); | ||
|
||
test('callback stays the same if state not in dependency list', () { |
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.
Nice tests here!
+10 |
Motivation
Support useCallback hook in react-dart
Changes
useCallback
functionPlease review: @kealjones-wk @aaronlademann-wf @greglittlefield-wf @joebingham-wk