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

Added code snippet for react-redux connected components #501

Merged
merged 5 commits into from Jul 2, 2020

Conversation

matthewnitschke-wk
Copy link
Contributor

@matthewnitschke-wk matthewnitschke-wk commented Jun 17, 2020

Motivation

Added a orStlessConnect snippet to generate the following:

import 'package:over_react/over_react.dart';
import 'package:over_react/over_react_redux.dart';

part 'FileName.over_react.g.dart';

UiFactory<MyComponentProps> MyComponent = connect<SomeReduxStoreState, MyComponentProps>(
  mapStateToProps: (state) => (MyComponent()),
  mapDispatchToProps: (dispatch) => (MyComponent()),
)(_$MyComponent); // ignore: undefined_identifier

mixin MyComponentProps on UiProps {}

class MyComponentComponent extends UiComponent2<MyComponentProps> {
  @override
  get defaultProps => (newProps());

  @override
  render() { }
}

Changes

Added above snippet for vscode and intelij

I do not have or use webstorm and the intelij snippet was manually created. This should probably be tested on an actual intelij product before merge

Release Notes

Add react-redux connected component snippets for both vscode and intlij

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

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

@matthewnitschke-wk matthewnitschke-wk marked this pull request as ready for review June 17, 2020 16:27
Copy link
Contributor

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

Thanks for your contribution @matthewnitschke-wk!

Couple of minor things:

  1. In the other snippets we omit the type on the left side of the defaultProps getter since it isn't necessary for the Dart type system to infer its type from super (Map).
  2. The return type of render is actually dynamic (render can return String, num, bool, FragmentElement, or ReactElement) - but it should be omitted altogether for the purpose of the snippet since that's how it is in all the other ones.
  3. The indentation of the lines within the component class should be 2 space indents, not 4 space continuations.
  4. The default value for the $MyState$ variable should not be the same as the component name, IMO... maybe something like "SomeReduxStoreState"?

Copy link
Contributor

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

+1

+10 for the WebStorm snippet

@kealjones-wk can you take the VsCode one for a spin when you have a chance?

@@ -42,3 +42,11 @@
<option name="DART" value="true" />
</context>
</template>
<template name="orStlessConnect" value="import 'package:over_react/over_react.dart';&#10;import 'package:over_react/over_react_redux.dart';&#10;&#10;part '$FileName$.over_react.g.dart';&#10;&#10;UiFactory&lt;$MyComponent$Props&gt; $MyComponent$ = connect&lt;$SomeReduxStoreState$, $MyComponent$Props&gt;(&#10; mapStateToProps: (state) =&gt; ($MyComponent$()),&#10; mapDispatchToProps: (dispatch) =&gt; ($MyComponent$()),&#10;)(_$$$MyComponent$); // ignore: undefined_identifier&#10;&#10;mixin $MyComponent$Props on UiProps {}&#10;&#10;class $MyComponent$Component extends UiComponent2&lt;$MyComponent$Props&gt; {&#10; @override&#10; get defaultProps =&gt; (newProps());&#10;&#10; @override&#10; render() { }&#10;}" description="Creates a stateless and connected over_react component" toReformat="false" toShortenFQNames="true">
Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM

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.

+10

@greglittlefield-wf
Copy link
Contributor

@Workiva/release-management-pp

Thanks for the contribution, @matthewnitschke-wk! ❤️

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

@rmconsole2-wf rmconsole2-wf merged commit 8b01ee5 into master Jul 2, 2020
@rmconsole2-wf rmconsole2-wf deleted the connected_snippet branch July 2, 2020 21:03
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.

None yet

6 participants