diff --git a/lib/over_react.dart b/lib/over_react.dart index 673c1607d..e4f6a35fd 100644 --- a/lib/over_react.dart +++ b/lib/over_react.dart @@ -57,7 +57,8 @@ export 'package:react/react_client.dart' setClientConfiguration, chainRefs, ReactElement, - ReactComponentFactoryProxy; + ReactComponentFactoryProxy, + ReactNode; export 'package:react/react_client/react_interop.dart' show ReactErrorInfo, Ref; export 'package:react/hooks.dart' show StateHook, ReducerHook; diff --git a/lib/react_dom.dart b/lib/react_dom.dart index 7b319546f..b2e85173e 100644 --- a/lib/react_dom.dart +++ b/lib/react_dom.dart @@ -44,7 +44,7 @@ import 'package:react/react_dom.dart' as react_dom show render, unmountComponent /// Use [unmountComponentAtNode] to unmount the instance. /// /// > Proxies [react_dom.render]. -dynamic render(/*ReactNode*/ dynamic element, Element mountNode) { +dynamic render(ReactNode element, Element mountNode) { return react_dom.render(element, mountNode); } diff --git a/lib/src/component/_deprecated/error_boundary_mixins.dart b/lib/src/component/_deprecated/error_boundary_mixins.dart index f245e7be9..966dd1777 100644 --- a/lib/src/component/_deprecated/error_boundary_mixins.dart +++ b/lib/src/component/_deprecated/error_boundary_mixins.dart @@ -102,7 +102,7 @@ abstract class _$ErrorBoundaryPropsMixin implements UiProps { /// component tree that crashed. /// /// > Related: [onComponentIsUnrecoverable], [onComponentDidCatch] - ReactElement Function(/*Error||Exception*/dynamic error, ReactErrorInfo? info)? fallbackUIRenderer; + ReactNode Function(/*Error||Exception*/dynamic error, ReactErrorInfo? info)? fallbackUIRenderer; /// The amount of time that is "acceptable" between consecutive identical errors thrown from a component /// within the tree wrapped by this [ErrorBoundary]. @@ -361,7 +361,7 @@ mixin ErrorBoundaryMixin @override - ReactElement Function(dynamic error, ReactErrorInfo? info)? + ReactNode Function(dynamic error, ReactErrorInfo? info)? get fallbackUIRenderer => (props[_$key__fallbackUIRenderer___$ErrorBoundaryPropsMixin] ?? null) - as ReactElement Function(dynamic error, ReactErrorInfo? info)?; + as ReactNode Function(dynamic error, ReactErrorInfo? info)?; /// A renderer that will be used to render "fallback" UI instead of the child /// component tree that crashed. @@ -148,7 +148,7 @@ abstract class ErrorBoundaryPropsMixin implements _$ErrorBoundaryPropsMixin { /// @override set fallbackUIRenderer( - ReactElement Function(dynamic error, ReactErrorInfo? info)? value) => + ReactNode Function(dynamic error, ReactErrorInfo? info)? value) => props[_$key__fallbackUIRenderer___$ErrorBoundaryPropsMixin] = value; /// The amount of time that is "acceptable" between consecutive identical errors thrown from a component diff --git a/lib/src/component/error_boundary.dart b/lib/src/component/error_boundary.dart index f0763b6f7..054033b76 100644 --- a/lib/src/component/error_boundary.dart +++ b/lib/src/component/error_boundary.dart @@ -73,7 +73,7 @@ mixin ErrorBoundaryProps on UiProps { /// component tree that crashed. /// /// > Related: [onComponentIsUnrecoverable], [onComponentDidCatch] - ReactElement? Function(/*Error||Exception*/dynamic error, ReactErrorInfo? info)? fallbackUIRenderer; + ReactNode Function(/*Error||Exception*/dynamic error, ReactErrorInfo? info)? fallbackUIRenderer; /// The amount of time that is "acceptable" between consecutive identical errors thrown from a component /// within the tree wrapped by this [ErrorBoundary]. diff --git a/lib/src/component/error_boundary.over_react.g.dart b/lib/src/component/error_boundary.over_react.g.dart index eaa0b84b2..239f9820e 100644 --- a/lib/src/component/error_boundary.over_react.g.dart +++ b/lib/src/component/error_boundary.over_react.g.dart @@ -280,13 +280,13 @@ mixin $ErrorBoundaryProps on ErrorBoundaryProps { Function(dynamic error, ReactErrorInfo info)? value) => props[_$key__onComponentIsUnrecoverable__ErrorBoundaryProps] = value; @override - ReactElement? Function(dynamic error, ReactErrorInfo? info)? + ReactNode Function(dynamic error, ReactErrorInfo? info)? get fallbackUIRenderer => (props[_$key__fallbackUIRenderer__ErrorBoundaryProps] ?? null) - as ReactElement? Function(dynamic error, ReactErrorInfo? info)?; + as ReactNode Function(dynamic error, ReactErrorInfo? info)?; @override set fallbackUIRenderer( - ReactElement? Function(dynamic error, ReactErrorInfo? info)? value) => + ReactNode Function(dynamic error, ReactErrorInfo? info)? value) => props[_$key__fallbackUIRenderer__ErrorBoundaryProps] = value; @override Duration? get identicalErrorFrequencyTolerance => diff --git a/lib/src/component/error_boundary_recoverable.dart b/lib/src/component/error_boundary_recoverable.dart index a7ea02c5c..b354b9a5b 100644 --- a/lib/src/component/error_boundary_recoverable.dart +++ b/lib/src/component/error_boundary_recoverable.dart @@ -189,7 +189,7 @@ class RecoverableErrorBoundaryComponent createRef() => react_interop.createRef(); /// _$Foo2Config, // ignore: undefined_identifier /// ); UiFactory uiForwardRef( - dynamic Function(TProps props, dynamic ref) functionComponent, dynamic _config) { + /*ReactNode*/ dynamic Function(TProps props, dynamic ref) functionComponent, dynamic _config) { ArgumentError.checkNotNull(_config, '_config'); if (_config is! UiFactoryConfig) { @@ -231,7 +231,7 @@ UiFactory uiForwardRef( // this will be an empty string. final displayName = config.displayName ?? getFunctionName(functionComponent); - dynamic _uiFunctionWrapper(JsBackedMap props, dynamic ref) { + /*ReactNode*/ dynamic _uiFunctionWrapper(JsBackedMap props, dynamic ref) { return functionComponent(propsFactory!.jsMap(props), ref); } diff --git a/lib/src/component/suspense_component.dart b/lib/src/component/suspense_component.dart index 08819958a..04b8eed42 100644 --- a/lib/src/component/suspense_component.dart +++ b/lib/src/component/suspense_component.dart @@ -67,11 +67,11 @@ mixin SuspensePropsMixin on UiProps { /// The actual UI you intend to render. If children suspends while rendering, the Suspense boundary will /// switch to rendering fallback. @override - /*ReactNode*/ List? get children; + List? get children; /// An alternate UI to render in place of the actual UI if it has not finished loading. Any valid React node is /// accepted, though in practice, a fallback is a lightweight placeholder view, such as a loading spinner or skeleton. /// Suspense will automatically switch to fallback when children suspends, and back to children when the data is ready. /// If fallback suspends while rendering, it will activate the closest parent Suspense boundary. - /*ReactNode*/ dynamic fallback; + ReactNode fallback; } diff --git a/lib/src/component/suspense_component.over_react.g.dart b/lib/src/component/suspense_component.over_react.g.dart index f84f72d45..a870e3998 100644 --- a/lib/src/component/suspense_component.over_react.g.dart +++ b/lib/src/component/suspense_component.over_react.g.dart @@ -14,10 +14,10 @@ part of 'suspense_component.dart'; mixin $SuspensePropsMixin on SuspensePropsMixin { static const PropsMeta meta = _$metaForSuspensePropsMixin; @override - dynamic get fallback => - (props[_$key__fallback__SuspensePropsMixin] ?? null) as dynamic; + ReactNode get fallback => + (props[_$key__fallback__SuspensePropsMixin] ?? null) as ReactNode; @override - set fallback(dynamic value) => + set fallback(ReactNode value) => props[_$key__fallback__SuspensePropsMixin] = value; /* GENERATED CONSTANTS */ static const PropDescriptor _$prop__fallback__SuspensePropsMixin = diff --git a/lib/src/component/with_transition.dart b/lib/src/component/with_transition.dart index f998d4ecd..2207cc67b 100644 --- a/lib/src/component/with_transition.dart +++ b/lib/src/component/with_transition.dart @@ -264,6 +264,8 @@ class WithTransitionComponent extends UiStatefulComponent2. // TODO: right now only top level factory declarations will generate props configs. UiFactory uiFunction( - dynamic Function(TProps props) functionComponent, + /*ReactNode*/ dynamic Function(TProps props) functionComponent, dynamic _config, ) { ArgumentError.checkNotNull(_config, '_config'); diff --git a/lib/src/over_react_redux/redux_multi_provider.dart b/lib/src/over_react_redux/redux_multi_provider.dart index f3b7c7e0c..cdd4f3a7a 100644 --- a/lib/src/over_react_redux/redux_multi_provider.dart +++ b/lib/src/over_react_redux/redux_multi_provider.dart @@ -77,7 +77,7 @@ class ReduxMultiProviderComponent @override render() { - dynamic content = props.children; + ReactNode content = props.children; props.storesByContext.forEach((context, store) { content = (ReduxProvider() ..store = store diff --git a/lib/src/util/react_util.dart b/lib/src/util/react_util.dart index 46d9d2c97..de85cf0ef 100644 --- a/lib/src/util/react_util.dart +++ b/lib/src/util/react_util.dart @@ -105,7 +105,7 @@ abstract class UiPropsMapView extends UiProps { Map get componentDefaultProps => throw UnimplementedError('@PropsMixin instances do not implement defaultProps'); @override - ReactElement build([dynamic children]) => + ReactElement build([ReactNode children]) => throw UnimplementedError('@PropsMixin instances do not implement build'); @override diff --git a/lib/src/util/react_wrappers.dart b/lib/src/util/react_wrappers.dart index 1164a1637..65906641b 100644 --- a/lib/src/util/react_wrappers.dart +++ b/lib/src/util/react_wrappers.dart @@ -203,7 +203,7 @@ Element? findDomNode(dynamic instance) => react_dom.findDOMNode(instance) as Ele /// [children] can be any renderable React child, such as a [ReactElement], [String], or fragment. /// /// See: -ReactPortal createPortal(dynamic children, Element container) => ReactDom.createPortal(children, container); +ReactPortal createPortal(ReactNode children, Element container) => ReactDom.createPortal(children, container); /// Dart wrapper for React.isValidElement. /// @@ -239,7 +239,7 @@ bool _isCompositeComponent(Object? instance) { /// * Children are likewise copied and potentially overwritten with [newChildren] as expected. /// * For JS components, a JS copy of [newProps] is returned, since React will merge the props without any special handling. /// If these values might contain event handlers -dynamic preparePropsChangeset(ReactElement element, Map? newProps, [Iterable? newChildren]) { +dynamic preparePropsChangeset(ReactElement element, Map? newProps, [Iterable? newChildren]) { final type = element.type; final dartComponentVersion = ReactDartComponentVersion.fromType(type); // ignore: invalid_use_of_protected_member @@ -293,7 +293,7 @@ external ReactElement _cloneElement(element, [props, children]); /// > Unlike React.addons.cloneWithProps, key and ref from the original element will be preserved. /// > There is no special behavior for merging any props (unlike cloneWithProps). /// > See the [v0.13 RC2 blog post](https://facebook.github.io/react/blog/2015/03/03/react-v0.13-rc2.html) for additional details. -ReactElement cloneElement(ReactElement element, [Map? props, Iterable? children]) { +ReactElement cloneElement(ReactElement element, [Map? props, Iterable? children]) { ArgumentError.checkNotNull(element, 'element'); var propsChangeset = preparePropsChangeset(element, props, children);