Skip to content

Commit

Permalink
Address CR feedback, misc typing cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
greglittlefield-wf committed Mar 6, 2019
1 parent e3fb375 commit fa614be
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
6 changes: 3 additions & 3 deletions lib/react.dart
Original file line number Diff line number Diff line change
Expand Up @@ -382,15 +382,15 @@ abstract class Component2Adapter {

/// Top-level ReactJS [Component class](https://facebook.github.io/react/docs/react-component.html)
/// which provides the [ReactJS Component API](https://facebook.github.io/react/docs/react-component.html#reference)
abstract class Component2<T extends Map> implements Component {
abstract class Component2 implements Component {
// TODO make private using expando?
Component2Adapter adapter;

@override
covariant T props;
Map props;

@override
covariant T state;
Map state;

@override
dynamic _jsThis;
Expand Down
9 changes: 2 additions & 7 deletions lib/react_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,7 @@ final ReactDartInteropStatics2 _dartInteropStatics2 = (() {

component
..jsThis = jsThis
// FIXME fix casts
..props = new JsBackedMap.backedBy(jsThis.props as dynamic);
..props = new JsBackedMap.backedBy(jsThis.props);

return component;
});
Expand All @@ -522,8 +521,7 @@ final ReactDartInteropStatics2 _dartInteropStatics2 = (() {
void handleComponentWillMount(Component2 component, ReactComponent jsThis) =>
zone.run(() {
component
// FIXME fix casts
..state = new JsBackedMap.backedBy(jsThis.state as dynamic);
..state = new JsBackedMap.backedBy(jsThis.state);

component.componentWillMount();
});
Expand All @@ -542,7 +540,6 @@ final ReactDartInteropStatics2 _dartInteropStatics2 = (() {
void _updatePropsAndStateWithJs(
Component2 component, JsMap props, JsMap state) {
component
// FIXME fix casts
..props = new JsBackedMap.backedBy(props)
..state = new JsBackedMap.backedBy(state);
}
Expand Down Expand Up @@ -576,8 +573,6 @@ final ReactDartInteropStatics2 _dartInteropStatics2 = (() {
void handleComponentDidUpdate(Component2 component, ReactComponent jsThis,
JsMap jsPrevProps, JsMap jsPrevState) =>
zone.run(() {
// final prevProps = component.props; // todo do this instead of creating new wrappers?
// final prevState = component.state; // todo do this instead of creating new wrappers?
component.componentDidUpdate(
new JsBackedMap.backedBy(jsPrevProps),
new JsBackedMap.backedBy(jsPrevState),
Expand Down
5 changes: 2 additions & 3 deletions lib/react_client/react_interop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class ReactElement {
class ReactComponent {
external Component get dartComponent;
external InteropProps get props;
external InteropProps get state;
external JsMap get state;
external get refs;
external void setState(state, [callback]);
external void forceUpdate([callback]);
Expand Down Expand Up @@ -193,7 +193,7 @@ class InteropContextValue {
/// __For internal/advanced use only.__
@JS()
@anonymous
class InteropProps {
class InteropProps implements JsMap {
@Deprecated('3.0.0')
external ReactDartComponentInternal get internal;
external dynamic get key;
Expand Down Expand Up @@ -328,7 +328,6 @@ bool get inReactDevMode => _inReactDevMode;
/// Will be removed when [Component] is removed in the `6.0.0` release.
@JS()
@anonymous

@Deprecated('6.0.0')
class ReactDartInteropStatics {
external factory ReactDartInteropStatics({
Expand Down
3 changes: 1 addition & 2 deletions test/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ Map getDartComponentProps(ReactComponent dartComponent) {

Map getDartElementProps(ReactElement dartElement) {
return isDartComponent2(dartElement)
? new JsBackedMap.fromJs(
dartElement.props as JsMap) // FIXME need to normalize event handlers?
? new JsBackedMap.fromJs(dartElement.props)
: dartElement.props.internal.props;
}

Expand Down

0 comments on commit fa614be

Please sign in to comment.