haseem
haseem

Reputation: 61

Webview not appearing in Expo Web

Working fine in expo mobile app, but same code doesn't show anything when opening Expo App on Web browser by running command expo start --web

Here is the sample code

    <WebView 
     originWhitelist={['*']} 
     source={{ uri: 'https://sofit.ltd' }}
     style={{marginBottom:100, height:"100%", width:"100%" }}
    />

Upvotes: 6

Views: 6475

Answers (2)

atlanteh
atlanteh

Reputation: 5835

For me the answer was to wrap it with a View:

<View style={styles.container}>
      <StatusBar style="auto" />
      <View style={styles.webviewContainer}>
        <WebView
            originWhitelist={['*']}
            source={{ uri: currentURI }}
            ref={webViewRef}
            style={styles.webview}
          />
      </View>
</View>

// Styles
const styles = StyleSheet.create({
  container: {
    marginTop: Constants.statusBarHeight,
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
  webview: {
    flex: 1,
  },
  webviewContainer: {
    flex: 1,
    alignSelf: 'stretch',
  },
});

Upvotes: 1

Oleg Levin
Oleg Levin

Reputation: 3621

Did you try in web only? try this snack: https://snack.expo.io/@djalik/webview-demo

Upvotes: 5

Related Questions