-
Notifications
You must be signed in to change notification settings - Fork 68
CPLAT-8035 Implement/Expose useEffect Hook #227
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.
I realized this wasn't in CR after i already wrote out the comment! sorry :P
# Conflicts: # example/test/function_component_test.dart
# Conflicts: # example/test/function_component_test.dart
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.
Just small nits, also, we might want to, similar too your useReducer example, label the useState / useEffect hooks components in the example page.
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.
Really minor feedback; looks great!
# Conflicts: # lib/hooks.dart # lib/react_client/react_interop.dart # test/hooks_test.dart
@@ -144,7 +144,7 @@ void useEffect(dynamic Function() sideEffect, [List<Object> dependencies]) { | |||
if (result is Function) { | |||
return allowInterop(result); | |||
} | |||
return null; | |||
return jsUndefined; |
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.
Could we add a comment saying why undefined is needed?
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.
Looking good @sydneyjodon-wk !
if (dependencies != null) { | ||
return React.useEffect(wrappedSideEffect, dependencies); |
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.
Is it ok / reasonably efficient to pass in an empty list here?
If not, we should probably check .isNotEmpty
in addition to != null
.
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.
Yes, passing an empty list is used if you just want to run an effect and clean it up only once (on mount and unmount)
b7cab0d
to
d65d845
Compare
# Conflicts: # example/test/function_component_test.dart
feedback addressed
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
Motivation
Support useEffect hook in react-dart
Changes
useEffect
functionPlease review: @kealjones-wk @aaronlademann-wf @greglittlefield-wf @joebingham-wk