22
33import com .google .gwt .dom .client .InputElement ;
44import com .google .gwt .user .client .Window ;
5+ import gwt .interop .utils .client .plainobjects .JsPlainObj ;
6+ import gwt .react .client .api .React ;
7+ import gwt .react .client .components .ReactClass ;
58import gwt .react .client .components .ReactClassSpec ;
69import gwt .react .client .elements .ReactElement ;
710import gwt .react .client .events .FormEvent ;
811import gwt .react .client .proptypes .BaseProps ;
912import gwt .react .client .proptypes .html .BtnProps ;
1013import gwt .react .client .proptypes .html .InputProps ;
11- import gwt .react .client .utils .ObjLiteral ;
1214import jsinterop .annotations .JsOverlay ;
1315import jsinterop .annotations .JsPackage ;
1416import jsinterop .annotations .JsType ;
1719
1820@ SuppressWarnings ("unused" )
1921@ JsType
20- class StatefulReactClassSpec extends ReactClassSpec <StatefulReactClassSpec .Props , StatefulReactClassSpec .State > {
22+ class StatefulExample extends ReactClassSpec <StatefulExample .Props , StatefulExample .State > {
2123
2224 @ JsType (isNative = true , namespace = JsPackage .GLOBAL , name ="Object" )
2325 static class Props extends BaseProps {
2426 String aProp ;
2527 }
2628
2729 @ JsType (isNative = true , namespace = JsPackage .GLOBAL , name ="Object" )
28- static class State extends ObjLiteral {
30+ static class State extends JsPlainObj {
2931 String aStateVar ;
3032
3133 @ JsOverlay
@@ -72,20 +74,20 @@ public void componentDidMount() {
7274 }
7375
7476 public void componentWillReceiveProps (Props nextProps ) {
75- Window .alert ("componentDidMount called (nextProps " + nextProps .toString () + ")" );
77+ Window .alert ("componentDidMount called (nextProps " + nextProps .toJSONString () + ")" );
7678 }
7779
7880 public boolean shouldComponentUpdate (Props nextProps , State nextState ) {
79- Window .alert ("componentWillReceiveProps called (nextProps " + nextProps .toString () + " nextState " + nextState .toString () + ")" );
81+ Window .alert ("componentWillReceiveProps called (nextProps " + nextProps .toJSONString () + " nextState " + nextState .toJSONString () + ")" );
8082 return true ;
8183 }
8284
8385 public void componentWillUpdate (Props nextProps , State nextState ) {
84- Window .alert ("componentWillUpdate called (nextProps " + nextProps .toString () + " nextState " + nextState .toString () + ")" );
86+ Window .alert ("componentWillUpdate called (nextProps " + nextProps .toJSONString () + " nextState " + nextState .toJSONString () + ")" );
8587 }
8688
8789 public void componentDidUpdate (Props prevProps , State prevState ) {
88- Window .alert ("componentDidUpdate called (prevProps " + prevProps .toString () + " prevState " + prevState .toString () + ")" );
90+ Window .alert ("componentDidUpdate called (prevProps " + prevProps .toJSONString () + " prevState " + prevState .toJSONString () + ")" );
8991 }
9092
9193 public void componentWillUnmount () {
@@ -95,4 +97,6 @@ public void componentWillUnmount() {
9597 private String getDescription () {
9698 return "Click Me (state=" + getState ().aStateVar + ", props=" + getProps ().aProp + ")" ;
9799 }
100+
101+ public static ReactClass <Props > component = React .createClass (new StatefulExample ());
98102}
0 commit comments