-
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
CPLAT-2272: Add UiComponent2 (JS-backed maps) #271
Conversation
# Conflicts: # lib/over_react.dart # lib/src/component_declaration/component_base.dart # lib/src/transformer/impl_generation.dart # pubspec.yaml
…previous member order
Security InsightsNo security relevant content was detected by automated scans. Action Items
Questions or Comments? Reach out on Slack: #support-infosec. |
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.
Should probably go ahead and deprecate all the old component classes.
..writeln(' // of `_$propsOrState` in the constructor body is necessary to work around a DDC bug: https://github.com/dart-lang/sdk/issues/36217') | ||
// TODO need to remove this workaround once https://github.com/dart-lang/sdk/issues/36217 is fixed get nice dart2js output | ||
..writeln(' $plainMapImplName(Map backingMap) : this._$propsOrState = {}, super._() {') | ||
..writeln(' this._$propsOrState = backingMap ?? {};') |
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.
Any benefit to making the fallback be const {}
?
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.
We can't because this map backs the returned props object, which can be mutated.
CPLAT-3300: CP Code Review and PR Merging Team agreement update
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.
+1
@@ -27,7 +27,7 @@ export 'package:react/react.dart' show | |||
SyntheticUIEvent, | |||
SyntheticWheelEvent; | |||
|
|||
// FIXME use public entrypoint | |||
// FIXME 3.0.0-wip use public entrypoint |
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.
@@ -31,6 +30,9 @@ import 'package:w_common/disposable.dart'; | |||
|
|||
export 'package:over_react/src/component_declaration/component_type_checking.dart' show isComponentOfType, isValidElementOfType; | |||
|
|||
part 'component_base/component_base_2.dart'; |
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.
❤️
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.
QA +1
@Workiva/release-management-pp
Ultimate problem:
Add over_react analogues of
Component2
, introduced in react-dart to implement JS-object-based props/state and to serve as the basis for React 16 lifecycle methods.See Workiva/react-dart#161 for more context
Changes
UiComponent2/
UiStatefulComponent2` base classesGenerate an additional UiProps class implementation for each component that can only be backed by JS maps, and override the return type of
typedPropsFactoryJs
/props
to match this.This allows dart2js to make some optimizations. For instance:
For the access of
props.isOpen
within a component, as we start to inline things (for the purposes of understanding what's going on under the hood), then it looks like this:So, we're eventually accessing a property on the
Map backingMap
.But if
backingMap
is aJsBackedMap
, we can go one layer deeper:Now, onto dart2js, which performs actual inlining in certain cases (like prop accesses).
When dart2js only knows that
backingMap
is aMap
, it emits the following code, wherein$index$asx
performs type-checking on the map and key, and then performs an interceptor lookup on the backing map before finally calling into the actual key lookup function.However, when dart2js knows that
backingMap
is aJsMap
, it can skip that step and emitcode that directly accesses the JS property
UiComponent2
to serve as a smoke branch as we finalize this work.@Required
annotation that was being tested, as well as related testsweb/
to useUi(Stateful)Component2
web/
withUiComponent2
versionsTesting
web/component2/
examples and verify their props/state show up in the dev tools as expected!Potential areas of regression: