Skip to content

Commit

Permalink
Revert breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronlademann-wf committed Mar 4, 2024
1 parent ab42c85 commit db249cf
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
8 changes: 4 additions & 4 deletions lib/react.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export 'package:react/src/react_client/synthetic_data_transfer.dart' show Synthe
/// See <https://reactjs.org/docs/components-and-props.html#function-and-class-components>.
///
/// [props] is typed as [JsBackedMap] so that dart2js can optimize props accesses.
typedef DartFunctionComponent = ReactNode Function(JsBackedMap props);
typedef DartFunctionComponent = /*ReactNode*/ dynamic Function(JsBackedMap props);

/// The callback to a React forwardRef component. See [forwardRef2] for more details.
///
Expand All @@ -39,7 +39,7 @@ typedef DartFunctionComponent = ReactNode Function(JsBackedMap props);
/// In the current JS implementation, the ref argument to [React.forwardRef] is usually a JsRef object no matter the input ref type,
/// 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
/// and not just a ref object, so we type [ref] as dynamic here.
typedef DartForwardRefFunctionComponent = ReactNode Function(JsBackedMap props, dynamic ref);
typedef DartForwardRefFunctionComponent = /*ReactNode*/ dynamic Function(JsBackedMap props, dynamic ref);

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

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

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

// ******************************************************************************************************************
//
Expand Down
4 changes: 2 additions & 2 deletions lib/react_client/react_interop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ ReactComponentFactoryProxy memo2(ReactComponentFactoryProxy factory,

abstract class ReactDom {
static Element? findDOMNode(ReactNode object) => ReactDOM.findDOMNode(object);
static ReactNode render(ReactNode component, Element element) => ReactDOM.render(component, element);
static dynamic render(ReactNode component, Element element) => ReactDOM.render(component, element);
static bool unmountComponentAtNode(Element element) => ReactDOM.unmountComponentAtNode(element);

/// Returns a a portal that renders [children] into a [container].
Expand Down Expand Up @@ -480,7 +480,7 @@ class ReactElement {
@JS()
@anonymous
class ReactPortal {
external ReactNode get children;
external dynamic /* ReactNodeList */ get children;
external dynamic get containerInfo;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:react/src/typedefs.dart';
@JS()
abstract class ReactDOM {
external static Element? findDOMNode(ReactNode object);
external static ReactNode render(ReactNode component, Element element);
external static dynamic render(ReactNode component, Element element);
external static bool unmountComponentAtNode(Element element);
external static ReactPortal createPortal(ReactNode children, Element container);
}
4 changes: 2 additions & 2 deletions lib/src/typedefs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ typedef CallbackRef<T> = Function(T? componentOrDomNode);
/// - [props] will always be supplied as the first argument
/// - [legacyContext] has been deprecated and should not be used but remains for backward compatibility and is necessary
/// to match Dart's generated call signature based on the number of args React provides.
typedef JsFunctionComponent = ReactNode Function(JsMap props, [JsMap? legacyContext]);
typedef JsFunctionComponent = /*ReactNode*/ dynamic Function(JsMap props, [JsMap? legacyContext]);

typedef JsForwardRefFunctionComponent = ReactNode Function(JsMap props, dynamic ref);
typedef JsForwardRefFunctionComponent = /*ReactNode*/ dynamic Function(JsMap props, dynamic ref);

/// Typedef for `react.Component.ref`, which should return one of the following specified by the provided [ref]:
///
Expand Down
4 changes: 1 addition & 3 deletions test/forward_ref_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ main() {

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

Expand Down

0 comments on commit db249cf

Please sign in to comment.