Skip to content

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

Merged
merged 33 commits into from
Jan 14, 2020

Conversation

sydneyjodon-wk
Copy link
Collaborator

@sydneyjodon-wk sydneyjodon-wk commented Nov 6, 2019

Motivation

Support useEffect hook in react-dart

Changes

  • Added useEffect function
  • Wrote tests.

Please review: @kealjones-wk @aaronlademann-wf @greglittlefield-wf @joebingham-wk

@sydneyjodon-wk sydneyjodon-wk changed the base branch from master to CPLAT-4309-react-hooks November 6, 2019 18:59
@sydneyjodon-wk sydneyjodon-wk changed the base branch from CPLAT-4309-react-hooks to CPLAT-8034-usestate-hook November 6, 2019 19:00
Copy link
Collaborator

@kealjones-wk kealjones-wk left a 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

Copy link
Collaborator

@kealjones-wk kealjones-wk left a 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.

@greglittlefield-wf greglittlefield-wf changed the base branch from CPLAT-8034-usestate-hook to 5.2.0-wip November 21, 2019 21:25
Copy link
Collaborator

@greglittlefield-wf greglittlefield-wf left a 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!

@@ -144,7 +144,7 @@ void useEffect(dynamic Function() sideEffect, [List<Object> dependencies]) {
if (result is Function) {
return allowInterop(result);
}
return null;
return jsUndefined;
Copy link
Collaborator

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?

Copy link
Collaborator

@aaronlademann-wf aaronlademann-wf left a 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 !

Comment on lines +152 to +153
if (dependencies != null) {
return React.useEffect(wrappedSideEffect, dependencies);
Copy link
Collaborator

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.

Copy link
Collaborator Author

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)

@aaronlademann-wf aaronlademann-wf changed the base branch from 5.2.0-wip to 5.3.0-wip December 11, 2019 22:44
@greglittlefield-wf greglittlefield-wf changed the base branch from 5.3.0-wip to 5.4.0-wip January 6, 2020 18:30
@greglittlefield-wf greglittlefield-wf dismissed stale reviews from kealjones-wk and aaronlademann-wf January 14, 2020 20:22

feedback addressed

Copy link
Collaborator

@greglittlefield-wf greglittlefield-wf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+10

@greglittlefield-wf greglittlefield-wf merged commit 8ec9e43 into 5.4.0-wip Jan 14, 2020
@aaronlademann-wf aaronlademann-wf added this to the 5.4.0 milestone Jan 29, 2020
@greglittlefield-wf greglittlefield-wf deleted the CPLAT-8035-useeffect-hook branch February 16, 2022 21:53
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.

4 participants