On Tue, Mar 15, 2016 at 8:26 PM, Paul Stockley <pstockl...@gmail.com> wrote:

> I have made a bit more progress. I managed to get functional components
> working.
>
> @JsType(isNative = true)
> private static class FuncProps extends BaseProps {
>     public String aProp;
> }
>
> static final public native FuncProps makeFuncProps() /*-{
>     return {};
> }-*/;
>
> @Override
> public void onModuleLoad() {
>     ClassicComponentClass<BaseProps> customClassicComponent = 
> React.createClass(CustomClassicComponent.makeSpec());
>
>     FunctionalComponent<FuncProps> funcComp =
>             (props)->{return React.createElement("div", null, "Functional 
> component works " + props.aProp);};
>
>     FuncProps fProps = makeFuncProps();
>     fProps.aProp = "Its a prop";
>
>     DOMElement<HTMLProps> div =
>             React.createElement("div", 
> Props.HTML()._defaultValue("ss")._accept("y"),
>                     React.createElement("div", null,
>                         React.createElement(funcComp, fProps)),
>                     React.createElement(customClassicComponent, null),
>                     React.createElement("div", null, "An example")
>             );
>
>     ReactDOM.render(div, Document.get().getElementById("mainCont"));
> }
>
>
>
> So far no luck with ES6 based components. Javascript object literals are a
> real pain to deal with in Java at the moment. I would like to be able to do
> "new FuncProps()" but it fails at runtime.
>

It would fail because the compiler will generate "new
some.package.name.FuncProps()" in JavaScript where
"some.package.name.FuncProps" is undefined. Point it to Global "Object" so
the generated code is "new Object" (which is same as "{}").


> So I have to resort to using JSNI to create the object. Having some sort
> of fluent interface like I defined for HTML props is about as close as you
> will get to the convenience of object literals in java. I could define a
> very generic javascript object like a map. This would be flexible but not
> very type safe.
>

There is a design for making it more elegant to work with such objects but
that is not planned for 2.8 release.


>
>
> --
> 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/0112d192-3aa1-4e0d-87ad-72ab2c862bc9%40googlegroups.com
> <https://groups.google.com/d/msgid/google-web-toolkit-contributors/0112d192-3aa1-4e0d-87ad-72ab2c862bc9%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAN%3DyUA1fh%2Ba0DDYvQju7-nUTUPA0R1iSGjmcp-LFVNaT5S4gRA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to