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

CPLAT-9347 Add memo for function components #613

Merged
merged 4 commits into from
Jul 30, 2020

Conversation

smaifullerton-wk
Copy link
Contributor

Motivation

We'd like a typed memo util to wrap the react-dart memo function to memoize function components.

Changes

  • Add memo with support for over_react typing for function components
  • Loosen types in signature of registerComponentTypeAlias so function components can be registered accordingly
  • Add enforceFunctionComponent util
  • Add unit tests for memo

Release Notes

Review

See CONTRIBUTING.md for more details on review types (+1 / QA +1 / +10) and code review process.

Please review:

QA Checklist

  • Tests were updated and provide good coverage of the changeset and other affected code
  • Manual testing was performed if needed

Merge Checklist

While we perform many automated checks before auto-merging, some manual checks are needed:

  • A Client Platform member has reviewed these changes
  • There are no unaddressed comments - this check can be automated if reviewers use the "Request Changes" feature
  • For release PRs - Version metadata in Rosie comment is correct

@aviary2-wf
Copy link

Security Insights

No security relevant content was detected by automated scans.

Action Items

  • Review PR for security impact; comment "security review required" if needed or unsure
  • Verify aviary.yaml coverage of security relevant code

Questions or Comments? Reach out on Slack: #support-infosec.

Copy link
Contributor

@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.

+1

Would be nice to address those ignore comments / formatting, but not a blocker for approval

Copy link
Contributor

@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.

+1

Copy link
Contributor

@joebingham-wk joebingham-wk left a comment

Choose a reason for hiding this comment

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

+1

QA'ing now!

Copy link
Contributor

@joebingham-wk joebingham-wk left a comment

Choose a reason for hiding this comment

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

QA'ing worked great! I just used the HOC in an example to verify it acted as I'd expect. Pulling it down though, I realize a small nit and then also - this PR doesn't add an export of the API to the over_react library. Let me know if there's a reason we weren't exporting, but I'd assume we'd want to.

Once the export is added (and nit addressed, if ya feel like it 🤷‍♂️ ), I can +10 and merge!

/// ```
///
/// `memo` only affects props changes. If your function component wrapped in `memo` has a
/// [useState] or [useContext] Hook in its implementation, it will still rerender when `state` or `context` change.
Copy link
Contributor

Choose a reason for hiding this comment

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

#nit there's just some lints from this (docs ref here):

Suggested change
/// [useState] or [useContext] Hook in its implementation, it will still rerender when `state` or `context` change.
/// `useState` or `useContext` Hook in its implementation, it will still rerender when `state` or `context` change.

@@ -74,6 +80,7 @@ export 'src/util/hoc.dart';
export 'src/util/handler_chain_util.dart';
export 'src/util/key_constants.dart';
export 'src/util/map_util.dart';
export 'src/util/memo.dart';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the only code change. The other changes are from ddev format

Copy link
Contributor

@joebingham-wk joebingham-wk left a comment

Choose a reason for hiding this comment

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

+10

@Workiva/release-management-p

Copy link

@rmconsole-wf rmconsole-wf left a comment

Choose a reason for hiding this comment

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

+1 from RM

@rmconsole6-wk rmconsole6-wk merged commit d937e52 into function-components-wip Jul 30, 2020
@rmconsole6-wk rmconsole6-wk deleted the cplat-9347-add-memo-hoc branch July 30, 2020 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants