Browse Source

Merge pull request #88 from notjiam/patch-1

Android WebView doesn't show when set style={{ width: ... }}
iou90 5 years ago
parent
commit
ce29b11a9a
No account linked to committer's email address
1 changed files with 4 additions and 4 deletions
  1. 4
    4
      autoHeightWebView/index.android.js

+ 4
- 4
autoHeightWebView/index.android.js View File

@@ -122,8 +122,8 @@ export default class AutoHeightWebView extends PureComponent {
122 122
     const { height: oldHeight, width: oldWidth, source: prevSource, script: prevScript } = state;
123 123
     const { style } = props;
124 124
     const { source, script } = getUpdatedState(props, getBaseScript);
125
-    const height = style ? style.height : null;
126
-    const width = style ? style.width : null;
125
+    const height = style && style.height ? style.height : null;
126
+    const width = style && style.width ? style.width : null;
127 127
     if (source.html !== prevSource.html || source.uri !== prevSource.uri || script !== prevScript) {
128 128
       return {
129 129
         source,
@@ -133,8 +133,8 @@ export default class AutoHeightWebView extends PureComponent {
133 133
     }
134 134
     if (isSizeChanged(height, oldHeight, width, oldWidth)) {
135 135
       return {
136
-        height,
137
-        width,
136
+        height: height ? height : oldHeight,
137
+        width: width ? width : oldWidth,
138 138
         isSizeChanged: true
139 139
       };
140 140
     }