Initial implementation of JS-object-based props/state
Implemented in new Component2 base class
This API is extremely far from final; it currently contains pieces that will be removed or completely reworked before release
Dart component props are now stored directly on the JS props object, as opposed to within a Dart object stored as an internal prop
Dart component state is now also stored directly on the JS state object, as opposed to completely within the Dart layer
Advantages:
Props/state are now visible/mutable in the React Dev Tools, greatly improving the Dart component debugging experience
Complexity of the Dart/JS bindings are reduced significantly by leveraging React JS logic more directly, allowing easier maintenance and reduced risk of bugs
This will be especially important when implementing the new React lifecycle methods and concurrent mode
Performance is increased by a small amount by avoiding Dart Map overhead
JsBackedMap
A Dart class that adapts JS objects to the Dart Map interface, allowing properties to be easily read/written directly.
Used as the basis for props/state Maps used in Component2's fields and lifecycle methods
Used to replace some existing logic in ReactDomComponentFactory that served similar functions, removing an extra copy in DOM ReactElement creation
Etc.
Update tests to run on Component2
Add basic tests for JsBackedMap (more test coverage will come in a later PR)
Changes
Initial implementation of JS-object-based props/state
Component2
base classprops
object, as opposed to within a Dart object stored as aninternal
propstate
object, as opposed to completely within the Dart layerAdvantages:
JsBackedMap
A Dart class that adapts JS objects to the Dart
Map
interface, allowing properties to be easily read/written directly.Component2
's fields and lifecycle methodsReactDomComponentFactory
that served similar functions, removing an extra copy in DOMReactElement
creationEtc.
Component2
Testing