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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions snippets/snippets.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,30 @@
"}"
],
"description": "Creates a stateful OverReact component with abbreviated props and state declarations"
},
"connectedStatelessComponent": {
"prefix": "orStlessConnect",
"body": [
"import 'package:over_react/over_react.dart';",
"import 'package:over_react/over_react_redux.dart';",
"",
"part '${1:FileName}.over_react.g.dart';",
"",
"UiFactory<${2:MyComponent}Props> ${2:MyComponent} = connect<${3:SomeReduxStoreState}, ${2:MyComponent}Props>(",
"\tmapStateToProps: (state) => (${2:MyComponent}()),",
"\tmapDispatchToProps: (dispatch) => (${2:MyComponent}()),",
")(_$${2:MyComponent}); // ignore: undefined_identifier",
"",
"mixin ${2:MyComponent}Props on UiProps {}",
"",
"class ${2:MyComponent}Component extends UiComponent2<${2:MyComponent}Props> {",
"\t@override",
"\tget defaultProps => (newProps());",
"",
"\t@override",
"\trender() { }",
"}"
],
"description": "Creates a stateless and connected OverReact component"
}
}
8 changes: 8 additions & 0 deletions snippets/snippets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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

<variable name="FileName" expression="" defaultValue="&quot;foo&quot;" alwaysStopAt="true" />
<variable name="MyComponent" expression="" defaultValue="&quot;Foo&quot;" alwaysStopAt="true" />
<variable name="SomeReduxStoreState" expression="" defaultValue="&quot;Foo&quot;" alwaysStopAt="true" />
<context>
<option name="DART" value="true" />
</context>
</template>