> > Well I think I have hit a roadblock with the current state of JsInterop. > Given the code below > >
> public class Example { > > @JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object") > private static class State extends BaseState { > public String aStateVar; > } > > static public BaseState getInitialState() { > State s = new State(); > s.aStateVar = "Initial Value"; > return s; > } > > protected static final native <S extends BaseState> S getState() /*-{; > return this.state; > }-*/; > > static public ReactElement<?> render() { > > //getState will not work because the this in the global JSNI function > is bound to $Wnd > State ourState = getState(); > > . > . > } > > public native JavaScriptObject makeSpec() /*-{ > return { > render : $entry(this.render()), > getInitialState : $entry(this.getInitialState()) > }; > }-*/; > > } > > The render method gets called fine and within this method this points to the react element. I need to get the state and props that are stored as variables. The problem is I have no way of getting this.props unless I use JSNI. The JSNI function created is defined on the global window object and this is bound to the window object. So I am dead in the water until I can get the class based component working. Even if I get this working I will face another issue. In ES6 components you normally have to bind any callbacks to the enclosing object.this. e.g. render() { return ( <div onClick={this.tick.bind(this)}> Clicks: {this.state .count} </div> ); } -- You received this message because you are subscribed to the Google Groups "GWT Contributors" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit-contributors+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/ac1fbf90-4b52-4a2e-9224-c4b16a218e17%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.