Skip to content

Commit f0bb218

Browse files
committed
Make rendering lazy (to avoid messing up implicts).
1 parent f37e392 commit f0bb218

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/coconut/react/View.hx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,19 @@ class ViewBase extends NativeComponent<{ vtree: RenderResult }, {}, ImplicitCont
3535
) {
3636
js.Syntax.code('{0}.call(this)', NativeComponent);
3737
this.__rendered = rendered;
38-
this.__react_state = __snap();
3938
this.__viewMounted = mounted;
4039
this.__viewUpdated = updated;
4140
this.__viewUnmounting = unmounting;
4241
}
4342

43+
@:noCompletion function __getRender()
44+
return (switch __react_state {
45+
case null: __snap();
46+
case v: v;
47+
}).vtree;
48+
4449
@:noCompletion function __snap():{ vtree: RenderResult }
45-
return { vtree: Observable.untracked(() -> __rendered.value) };
50+
return { vtree: __rendered.value };
4651

4752
@:keep @:noCompletion @:final function componentDidMount() {
4853
if (__viewMounted != null) __viewMounted();
@@ -62,13 +67,13 @@ class ViewBase extends NativeComponent<{ vtree: RenderResult }, {}, ImplicitCont
6267
}
6368

6469
@:keep @:noCompletion @:final function shouldComponentUpdate(_, next:{ vtree: RenderResult })
65-
return __react_state.vtree != next.vtree;
70+
return __getRender() != next.vtree;
6671

6772
@:keep @:noCompletion @:final @:native('render') function reactRender() {
6873
if (this.__binding == null) {
6974
this.__binding = new Binding(this);
7075
}
71-
return switch this.__react_state.vtree {
76+
return switch __getRender() {
7277
case js.Syntax.typeof(_) => 'undefined': null;
7378
case v: v;
7479
}

0 commit comments

Comments
 (0)