From 54a51c87695c7bae0e2105b12db9f919b67eaa6f Mon Sep 17 00:00:00 2001 From: keepsimple7 Date: Thu, 27 Oct 2016 17:11:52 -0700 Subject: [PATCH] Make fields private + So that over_react can override them with strong typing + Ref: https://github.com/Workiva/over_react/issues/14 --- lib/react.dart | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/react.dart b/lib/react.dart index 428baba..524d3b9 100644 --- a/lib/react.dart +++ b/lib/react.dart @@ -5,14 +5,28 @@ /// A Dart library for building UI using ReactJS. library react; +import 'dart:html'; + /// Top-level ReactJS [Component class](https://facebook.github.io/react/docs/top-level-api.html#react.component) /// which provides the [ReactJS Component API](https://facebook.github.io/react/docs/component-api.html) abstract class Component { + Map _props; + Map _state = {}; + dynamic _ref; + /// ReactJS `Component` props. - Map props; + Map get props => _props; + set props(Map value) => _props = value; - /// Provides access to the underlying DOM representation of the [render]ed `Component`. - dynamic ref; + /// ReactJS `Component` state. + Map get state => _state; + set state(Map value) => _state = value; + + /// Returns the component of the specified [ref]. + /// + /// Returns a [Component] if it is a Dart component, otherwise returns an "Dom component" ([Element]). + dynamic get ref => _ref; + set ref(dynamic value) => _ref = value; dynamic _jsRedraw; @@ -57,9 +71,6 @@ abstract class Component { transferComponentState(); } - /// ReactJS `Component` state. - Map state = {}; - /// Private reference to the value of [state] from the previous render cycle. /// /// Useful for ReactJS lifecycle methods [shouldComponentUpdate], [componentWillUpdate] and [componentDidUpdate].