Skip to content

Commit db249cf

Browse files
Revert breaking changes
1 parent ab42c85 commit db249cf

File tree

5 files changed

+10
-12
lines changed

5 files changed

+10
-12
lines changed

lib/react.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export 'package:react/src/react_client/synthetic_data_transfer.dart' show Synthe
3030
/// See <https://reactjs.org/docs/components-and-props.html#function-and-class-components>.
3131
///
3232
/// [props] is typed as [JsBackedMap] so that dart2js can optimize props accesses.
33-
typedef DartFunctionComponent = ReactNode Function(JsBackedMap props);
33+
typedef DartFunctionComponent = /*ReactNode*/ dynamic Function(JsBackedMap props);
3434

3535
/// The callback to a React forwardRef component. See [forwardRef2] for more details.
3636
///
@@ -39,7 +39,7 @@ typedef DartFunctionComponent = ReactNode Function(JsBackedMap props);
3939
/// In the current JS implementation, the ref argument to [React.forwardRef] is usually a JsRef object no matter the input ref type,
4040
/// but according to React the ref argument can be any ref type: https://github.com/facebook/flow/blob/master@%7B2020-09-08%7D/lib/react.js#L305
4141
/// and not just a ref object, so we type [ref] as dynamic here.
42-
typedef DartForwardRefFunctionComponent = ReactNode Function(JsBackedMap props, dynamic ref);
42+
typedef DartForwardRefFunctionComponent = /*ReactNode*/ dynamic Function(JsBackedMap props, dynamic ref);
4343

4444
typedef ComponentFactory<T extends Component> = T Function();
4545

@@ -545,7 +545,7 @@ abstract class Component {
545545
/// When called, it should examine [props] and [state] and return a [ReactNode].
546546
///
547547
/// See: <https://legacy.reactjs.org/docs/react-component.html#render>
548-
ReactNode render();
548+
/*ReactNode*/ dynamic render();
549549
}
550550

551551
/// Top-level ReactJS [Component class](https://reactjs.org/docs/react-component.html)
@@ -943,7 +943,7 @@ abstract class Component2 implements Component {
943943
///
944944
/// See: <https://legacy.reactjs.org/docs/react-component.html#render>
945945
@override
946-
ReactNode render();
946+
/*ReactNode*/ dynamic render();
947947

948948
// ******************************************************************************************************************
949949
//

lib/react_client/react_interop.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ ReactComponentFactoryProxy memo2(ReactComponentFactoryProxy factory,
276276

277277
abstract class ReactDom {
278278
static Element? findDOMNode(ReactNode object) => ReactDOM.findDOMNode(object);
279-
static ReactNode render(ReactNode component, Element element) => ReactDOM.render(component, element);
279+
static dynamic render(ReactNode component, Element element) => ReactDOM.render(component, element);
280280
static bool unmountComponentAtNode(Element element) => ReactDOM.unmountComponentAtNode(element);
281281

282282
/// Returns a a portal that renders [children] into a [container].
@@ -480,7 +480,7 @@ class ReactElement {
480480
@JS()
481481
@anonymous
482482
class ReactPortal {
483-
external ReactNode get children;
483+
external dynamic /* ReactNodeList */ get children;
484484
external dynamic get containerInfo;
485485
}
486486

lib/src/react_client/dart2_interop_workaround_bindings.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import 'package:react/src/typedefs.dart';
1010
@JS()
1111
abstract class ReactDOM {
1212
external static Element? findDOMNode(ReactNode object);
13-
external static ReactNode render(ReactNode component, Element element);
13+
external static dynamic render(ReactNode component, Element element);
1414
external static bool unmountComponentAtNode(Element element);
1515
external static ReactPortal createPortal(ReactNode children, Element container);
1616
}

lib/src/typedefs.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ typedef CallbackRef<T> = Function(T? componentOrDomNode);
1313
/// - [props] will always be supplied as the first argument
1414
/// - [legacyContext] has been deprecated and should not be used but remains for backward compatibility and is necessary
1515
/// to match Dart's generated call signature based on the number of args React provides.
16-
typedef JsFunctionComponent = ReactNode Function(JsMap props, [JsMap? legacyContext]);
16+
typedef JsFunctionComponent = /*ReactNode*/ dynamic Function(JsMap props, [JsMap? legacyContext]);
1717

18-
typedef JsForwardRefFunctionComponent = ReactNode Function(JsMap props, dynamic ref);
18+
typedef JsForwardRefFunctionComponent = /*ReactNode*/ dynamic Function(JsMap props, dynamic ref);
1919

2020
/// Typedef for `react.Component.ref`, which should return one of the following specified by the provided [ref]:
2121
///

test/forward_ref_test.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ main() {
3030

3131
group('sets name on the rendered component as expected', () {
3232
test('unless the displayName argument is not passed to forwardRef2', () {
33-
final ForwardRefTestComponent = forwardRef2((props, ref) {
34-
return null;
35-
});
33+
final ForwardRefTestComponent = forwardRef2((props, ref) {});
3634
expect(getProperty(getProperty(ForwardRefTestComponent.type as Object, 'render'), 'name'), anyOf('', isNull));
3735
});
3836

0 commit comments

Comments
 (0)