-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UIP-1897: Add support for traversing wrapper components to getProps #48
UIP-1897: Add support for traversing wrapper components to getProps #48
Conversation
RavenNumber of Findings: 0 |
Codecov Report
@@ Coverage Diff @@
## master #48 +/- ##
==========================================
+ Coverage 97.65% 97.67% +0.02%
==========================================
Files 28 28
Lines 1318 1329 +11
==========================================
+ Hits 1287 1298 +11
Misses 31 31 Continue to review full report at Codecov.
|
UIP-1897 - Get the component type meta of Dart ReactComponents by using the JS constructor as the type alias.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great @jacehensley-wf! Just a few typos / doc comments update.
lib/src/util/react_wrappers.dart
Outdated
@@ -108,10 +109,34 @@ Expando<UnmodifiableMapView> _elementPropsCache = new Expando('_elementPropsCach | |||
/// For a JS component, this returns the result of [getJsProps] in an unmodifiable Map view. | |||
/// | |||
/// Throws if [instance] is not a valid [ReactElement] or composite [ReactComponent] . | |||
Map getProps(/* ReactElement|ReactComponent */ instance) { | |||
Map getProps(/* ReactElement|ReactComponent */ instance, {bool traverseWrappers: false}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jacehensley-wf the doc comment should be updated to explain the use case of setting traverseWrappers
to true
.
@@ -574,6 +576,264 @@ main() { | |||
})); | |||
}); | |||
|
|||
group('traverses children of Wrapper components', () { | |||
group('and retruns props for a', () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/retruns/returns
})); | ||
}); | ||
|
||
test('except when traversWrappers is false', () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/traversWrappers/traverseWrappers
})); | ||
}); | ||
|
||
test('except when traversWrappers is false', () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/traversWrappers/traverseWrappers
})); | ||
}); | ||
|
||
test('except when traversWrappers is false', () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/traversWrappers/traverseWrappers
})); | ||
}); | ||
|
||
test('except when traverseWrapers is false', () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/traverseWrapers/traverseWrappers
lib/src/util/react_wrappers.dart
Outdated
ComponentTypeMeta instanceTypeMeta; | ||
|
||
if (isCompositeComponent && isDartComponent(instance)) { | ||
var reactClassType = getProperty(getDartComponent(instance).jsThis, 'constructor'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I wasn't more clear on what I meant here; I was suggesting something like:
ReactClass type = getProperty(getDartComponent(instance).jsThis, 'constructor');
instanceTypeMeta = getComponentTypeMeta(type);
UIP-1897
@greglittlefield-wf @aaronlademann-wf Feedback has been addressed. |
+1 |
+1 |
}, testChildren) | ||
)); | ||
|
||
expect(getProps(renderedInstance), isNot({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would probably be better to verify explicitly that the OneLevelWrapper
's props are returned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Same goes for other analogous tests)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why this is still here. This has been addressed.
@@ -574,6 +576,264 @@ main() { | |||
})); | |||
}); | |||
|
|||
group('traverses children of Wrapper components', () { | |||
group('and returns props for a', () { | |||
group('composite JS ReactComponent', () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like composite JS ReactElements aren't tested
}); | ||
}); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd probably be good to also test that getProps
w/ traverseWrappers: true
doesn't have any issues when passed a non-wrapper component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed
A few comments around tests, but otherwise looks great |
UIP-1897
UIP-1897
@greglittlefield-wf feedback has been addressed |
+1 |
QA Resource Approval: +10
Merging. |
Ultimate problem:
getProps
did not support traversing "Wrapper" components.How it was fixed:
traverseWrappers
togetProps
ReactElements
and DartReactComponents
.Also done:
Testing suggestions:
Potential areas of regression: