Skip to content

Commit 13aa616

Browse files
authored
Fixed waitForRender in Android (#8143)
1 parent dd71fc9 commit 13aa616

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

lib/android/app/src/main/java/com/reactnativenavigation/react/ReactView.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import android.os.Bundle;
88
import android.view.MotionEvent;
99
import android.view.View;
10+
import android.view.ViewGroup;
1011
import android.widget.FrameLayout;
1112

1213
import androidx.annotation.RestrictTo;
@@ -71,15 +72,15 @@ public void destroy() {
7172
}
7273

7374
public void sendComponentWillStart(ComponentType type) {
74-
this.post(()->{
75+
this.post(() -> {
7576
ReactContext currentReactContext = getReactContext();
7677
if (currentReactContext != null)
7778
new EventEmitter(currentReactContext).emitComponentWillAppear(componentId, componentName, type);
7879
});
7980
}
8081

8182
public void sendComponentStart(ComponentType type) {
82-
this.post(()->{
83+
this.post(() -> {
8384
ReactContext currentReactContext = getReactContext();
8485
if (currentReactContext != null) {
8586
new EventEmitter(currentReactContext).emitComponentDidAppear(componentId, componentName, type);
@@ -117,7 +118,12 @@ public void dispatchTouchEventToJs(MotionEvent event) {
117118

118119
@Override
119120
public boolean isRendered() {
120-
return getChildCount() >= 1;
121+
ViewGroup view = reactSurface.getView();
122+
if (view != null) {
123+
return view.getChildCount() >= 1;
124+
}
125+
126+
return false;
121127
}
122128

123129
public EventDispatcher getEventDispatcher() {
@@ -131,7 +137,7 @@ public String getComponentName() {
131137
}
132138

133139
private ReactHost getReactHost() {
134-
return ((ReactApplication)getContext().getApplicationContext()).getReactHost();
140+
return ((ReactApplication) getContext().getApplicationContext()).getReactHost();
135141
}
136142

137143
private ReactContext getReactContext() {

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)