From 8b01ee53f715a89885e89ebb283645d682efefb5 Mon Sep 17 00:00:00 2001 From: Matthew Nitschke <39171685+matthewnitschke-wk@users.noreply.github.com> Date: Thu, 2 Jul 2020 15:03:54 -0600 Subject: [PATCH] Added code snippet for react-redux connected components (#501) * added vscode snippets for connected components * added intelij snippet * removed extra ignore comment * formatted json file * address pr comments --- snippets/snippets.json | 25 +++++++++++++++++++++++++ snippets/snippets.xml | 8 ++++++++ 2 files changed, 33 insertions(+) diff --git a/snippets/snippets.json b/snippets/snippets.json index 28e5f7fd4..322e3656c 100644 --- a/snippets/snippets.json +++ b/snippets/snippets.json @@ -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" } } diff --git a/snippets/snippets.xml b/snippets/snippets.xml index 82aff5d60..486acec0d 100644 --- a/snippets/snippets.xml +++ b/snippets/snippets.xml @@ -42,3 +42,11 @@ <option name="DART" value="true" /> </context> </template> +<template name="orStlessConnect" value="import 'package:over_react/over_react.dart'; import 'package:over_react/over_react_redux.dart'; part '$FileName$.over_react.g.dart'; UiFactory<$MyComponent$Props> $MyComponent$ = connect<$SomeReduxStoreState$, $MyComponent$Props>( mapStateToProps: (state) => ($MyComponent$()), mapDispatchToProps: (dispatch) => ($MyComponent$()), )(_$$$MyComponent$); // ignore: undefined_identifier mixin $MyComponent$Props on UiProps {} class $MyComponent$Component extends UiComponent2<$MyComponent$Props> { @override get defaultProps => (newProps()); @override render() { } }" description="Creates a stateless and connected over_react component" toReformat="false" toShortenFQNames="true"> + <variable name="FileName" expression="" defaultValue=""foo"" alwaysStopAt="true" /> + <variable name="MyComponent" expression="" defaultValue=""Foo"" alwaysStopAt="true" /> + <variable name="SomeReduxStoreState" expression="" defaultValue=""Foo"" alwaysStopAt="true" /> + <context> + <option name="DART" value="true" /> + </context> +</template>