From 378a58d34b261a401c7961f32542a5d44f52cf63 Mon Sep 17 00:00:00 2001 From: Joe Bingham Date: Wed, 5 Aug 2020 08:54:18 -0700 Subject: [PATCH] Fix CI --- lib/src/component/ref_util.dart | 37 ++++++++----------- test/over_react/component/ref_util_test.dart | 8 ++-- test/vm_tests/builder/codegen_test.dart | 2 +- .../builder/declaration_parsing_test.dart | 2 +- 4 files changed, 22 insertions(+), 27 deletions(-) diff --git a/lib/src/component/ref_util.dart b/lib/src/component/ref_util.dart index 6092e1170..6d22c268b 100644 --- a/lib/src/component/ref_util.dart +++ b/lib/src/component/ref_util.dart @@ -177,11 +177,11 @@ Ref createRef() { /// /// Learn more: . UiFactory Function(UiFactory) forwardRef( - Function(TProps props, Ref ref) wrapperFunction, {String displayName}) { - + Function(TProps props, Ref ref) wrapperFunction, + {String displayName}) { UiFactory wrapWithForwardRef(UiFactory factory) { enforceMinimumComponentVersionFor(factory().componentFactory); - + if (displayName == null) { final componentFactoryType = factory().componentFactory.type; if (componentFactoryType is String) { @@ -197,10 +197,11 @@ UiFactory Function(UiFactory) forwardRef } } } - + Object wrapProps(Map props, Ref ref) { return wrapperFunction(factory(props), ref); } + ReactComponentFactoryProxy hoc = react_interop.forwardRef(wrapProps, displayName: displayName); setComponentTypeMeta(hoc, isHoc: true, parentType: factory().componentFactory); @@ -216,9 +217,6 @@ UiFactory Function(UiFactory) forwardRef /// Automatically passes a [Ref] through a component to one of its children. /// -/// > __NOTE:__ This should only be used to wrap components that extend from `Component2` -/// > or components using the function syntax. -/// /// __Example 1:__ Forwarding refs to DOM components /// /// ```dart @@ -283,20 +281,20 @@ UiFactory Function(UiFactory) forwardRef /// /// // ---------- Wrapping a Class Component ---------- /// // Here you have two options: -/// // - Option 1: Use the class component's UI Factory to construct a function +/// // - Option 1: Use the class component's UI Factory to construct a UI /// // component config. This needs to be done because the builder recognizes /// // `LogPropsProps` as already consumed (by the class component). /// // /// // - Option 2: Create a new props class. This just works around the issue /// // described for Option 1 because it is creating a new props class, but it -/// // only needs to mixin in the props mixins that the original props class used. +/// // only needs to mix in the props mixins that the original props class used. /// // -/// // Choosing between the options is likely circumstantial or at least preferential -/// // if all else is the same. The advantage to Option 1 is that if the class component -/// // has numerous mixins, it is much more concise to create the function component -/// // config. Option 2 has the benefit that it matches the declaration of standard +/// // Choosing between the options is likely circumstantial or preferential. +/// // The advantage to Option 1 is that if the class component has numerous mixins, +/// // it is much more concise to create the function component config. +/// // Option 2 has the benefit that it matches the declaration of standard /// // function components (which `uiForwardRef` returns). Additionally, Option 2 -/// // illustrates how one could add additional props to the wrapping function component. +/// // illustrates how one could add additional props to the wrapped function component. /// /// // Option 1 Example /// final LogsPropsComponent = uiForwardRef((props, ref) { @@ -449,8 +447,7 @@ UiFactory Function(UiFactory) forwardRef /// /// Learn more: . UiFactory uiForwardRef( - dynamic Function(TProps props, dynamic ref) functionComponent, - UiFactoryConfig config) { + dynamic Function(TProps props, dynamic ref) functionComponent, UiFactoryConfig config) { ArgumentError.checkNotNull(config, 'config'); // ignore: invalid_use_of_protected_member @@ -475,12 +472,10 @@ UiFactory uiForwardRef( if (propsFactory == null) { if (TProps != UiProps && TProps != GenericUiProps) { - throw ArgumentError( - 'config.propsFactory must be provided when using custom props classes'); + throw ArgumentError('config.propsFactory must be provided when using custom props classes'); } - propsFactory = PropsFactory.fromUiFactory( - ([backingMap]) => GenericUiProps(factory, backingMap)) - as PropsFactory; + propsFactory = PropsFactory.fromUiFactory(([backingMap]) => GenericUiProps(factory, backingMap)) + as PropsFactory; } TProps _uiFactory([Map backingMap]) { diff --git a/test/over_react/component/ref_util_test.dart b/test/over_react/component/ref_util_test.dart index 064957d1b..eddea6749 100644 --- a/test/over_react/component/ref_util_test.dart +++ b/test/over_react/component/ref_util_test.dart @@ -47,7 +47,7 @@ main() { }); group('on a function component child', () { - standardForwardRefTest(BasicChild, verifyRefValue: (ref) { + testForwardRefWith(BasicChild, verifyRefValue: (ref) { expect(ref, TypeMatcher()); }, useUiForwardRef: true); @@ -180,7 +180,7 @@ void commonRefForwardingTests({bool useUiForwardRef = false}) { group('- commonRefForwardingTests -', () { group('on a component with a dom component child', () { - standardForwardRefTest(Dom.span, verifyRefValue: (ref) { + testForwardRefWith(Dom.span, verifyRefValue: (ref) { expect(ref, TypeMatcher()); }, useUiForwardRef: useUiForwardRef); @@ -227,7 +227,7 @@ void commonRefForwardingTests({bool useUiForwardRef = false}) { }); group('on a component with a dart component child', () { - standardForwardRefTest(Basic, verifyRefValue: (ref) { + testForwardRefWith(Basic, verifyRefValue: (ref) { expect(ref, TypeMatcher()); }, useUiForwardRef: useUiForwardRef); @@ -267,7 +267,7 @@ void commonRefForwardingTests({bool useUiForwardRef = false}) { const displayName = 'AVerySpecificDisplayName'; -void standardForwardRefTest(dynamic factory, +void testForwardRefWith(dynamic factory, {void Function(dynamic refValue) verifyRefValue, useUiForwardRef = false}) { test('- passes a ref through the parent to its child', () { UiFactory BasicForwarded = useUiForwardRef diff --git a/test/vm_tests/builder/codegen_test.dart b/test/vm_tests/builder/codegen_test.dart index fad51b903..f54e03e8c 100644 --- a/test/vm_tests/builder/codegen_test.dart +++ b/test/vm_tests/builder/codegen_test.dart @@ -707,7 +707,7 @@ main() { (props) { return Dom.div()(); }, - $BarPropsMixinConfig, // ignore: undefined_identifier + $BarConfig, // ignore: undefined_identifier ); final Foo = uiFunction( diff --git a/test/vm_tests/builder/declaration_parsing_test.dart b/test/vm_tests/builder/declaration_parsing_test.dart index 8415f7f0d..35b199f0d 100644 --- a/test/vm_tests/builder/declaration_parsing_test.dart +++ b/test/vm_tests/builder/declaration_parsing_test.dart @@ -1665,7 +1665,7 @@ main() { (props) { return Dom.div()(); }, - \$FooConfig, // ignore: undefined_identifier + \$BarConfig, // ignore: undefined_identifier )); final Foo2 = someHOC(uiFunction(