From 09d0a682e266c23b2759f44222a9ce6d751a16a8 Mon Sep 17 00:00:00 2001 From: Greg Littlefield Date: Tue, 7 Nov 2023 11:53:38 -0700 Subject: [PATCH] Fix warnings --- example/test/get_dom_node_test.dart | 4 ++-- example/test/unmount_test.dart | 2 +- lib/react_dom.dart | 2 -- lib/react_test_utils.dart | 10 +++++----- lib/src/react_client/private_utils.dart | 3 +-- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/example/test/get_dom_node_test.dart b/example/test/get_dom_node_test.dart index 65937685..cdc81ce2 100644 --- a/example/test/get_dom_node_test.dart +++ b/example/test/get_dom_node_test.dart @@ -40,11 +40,11 @@ class _SimpleComponent extends react.Component2 { var refToElement; @override - componentWillUnmount() => print("unmount"); + componentWillUnmount() => print('unmount'); @override componentDidMount() { - print("mount"); + print('mount'); customAssert('ref to span return span ', refToSpan.text == 'Test'); // ignore: deprecated_member_use_from_same_package customAssert('findDOMNode works on this', react_dom.findDOMNode(this) != null); diff --git a/example/test/unmount_test.dart b/example/test/unmount_test.dart index 136bb76d..dbe7c3d4 100644 --- a/example/test/unmount_test.dart +++ b/example/test/unmount_test.dart @@ -8,7 +8,7 @@ var SimpleComponent = react.registerComponent2(() => _SimpleComponent()); class _SimpleComponent extends react.Component2 { @override - componentDidMount() => print("mount"); + componentDidMount() => print('mount'); @override componentWillUnmount() => print('unmount'); diff --git a/lib/react_dom.dart b/lib/react_dom.dart index fb3616e2..a70b6514 100644 --- a/lib/react_dom.dart +++ b/lib/react_dom.dart @@ -5,8 +5,6 @@ library react_dom; // ignore: deprecated_member_use_from_same_package -import 'dart:html'; - import 'package:react/react.dart' show Component; import 'package:react/react_client/react_interop.dart' show ReactDom; import 'package:react/src/react_client/create_root.dart' show ReactRoot, createRoot; diff --git a/lib/react_test_utils.dart b/lib/react_test_utils.dart index 9a1e1964..c7e60aa6 100644 --- a/lib/react_test_utils.dart +++ b/lib/react_test_utils.dart @@ -37,7 +37,7 @@ import 'package:react/src/react_test_utils/internal_test_utils.dart' as itu; /// * For DOM components, this with return the String corresponding to its tagName ('div', 'a', etc.). /// * For custom composite components React.createClass()-based components, this will return the [ReactClass]. @Deprecated('Use the react_testing_library package instead.') -final getComponentTypeV2 = itu.getComponentTypeV2; +const getComponentTypeV2 = itu.getComponentTypeV2; @Deprecated('Use the react_testing_library package instead.') typedef ComponentTestFunction = bool Function(dynamic /* [1] */ component); @@ -155,17 +155,17 @@ external dynamic /* [1] */ _findRenderedComponentWithType(/* [1] */ tree, dynami /// Returns true if element is a composite component. /// (created with React.createClass()). @Deprecated('Use the react_testing_library package instead.') -final isCompositeComponent = itu.isCompositeComponent; +const isCompositeComponent = itu.isCompositeComponent; /// Returns `true` if instance is a custom composite component created using `React.createClass()` /// that is of the [ReactComponentFactoryProxy.type] of the provided [componentFactory]. @Deprecated('Use the react_testing_library package instead.') -final isCompositeComponentWithTypeV2 = itu.isCompositeComponentWithTypeV2; +const isCompositeComponentWithTypeV2 = itu.isCompositeComponentWithTypeV2; /// Returns true if instance is a DOM component (such as a
or ). @JS('React.addons.TestUtils.isDOMComponent') @Deprecated('Use the react_testing_library package instead.') -final isDOMComponent = itu.isDOMComponent; +const isDOMComponent = itu.isDOMComponent; /// Returns true if [object] is a valid React component. @JS('React.addons.TestUtils.isElement') @@ -175,7 +175,7 @@ external bool isElement(dynamic object); /// Returns `true` if [element] is a [ReactElement] /// that is of the [ReactComponentFactoryProxy.type] of the provided [componentFactory]. @Deprecated('Use the react_testing_library package instead.') -final isElementOfTypeV2 = itu.isElementOfTypeV2; +const isElementOfTypeV2 = itu.isElementOfTypeV2; @JS('React.addons.TestUtils.scryRenderedComponentsWithType') external List /* [1] */ _scryRenderedComponentsWithType(/* [1] */ tree, dynamic type); diff --git a/lib/src/react_client/private_utils.dart b/lib/src/react_client/private_utils.dart index 09ce1cf0..f0123cce 100644 --- a/lib/src/react_client/private_utils.dart +++ b/lib/src/react_client/private_utils.dart @@ -58,10 +58,9 @@ void validateJsApi() { createReactDartComponentClass(null, null, null); createReactDartComponentClass2(null, null, null); _isJsApiValid = true; - } on NoSuchMethodError catch (e) { + } on NoSuchMethodError catch (_) { throw Exception('react.js and react_dom.js must be loaded.'); } catch (_) { - rethrow; throw Exception('Loaded react.js must include react-dart JS interop helpers.'); } }