0

i am new to developing react-native application in which i need to link html file.it gives blank output on my android emulator, even not any error. I just want to know how to link html file with react native. Basic code samples are given below..

i have gone through the this below link but it is not working in my scenario.. (React Native) Load local HTML file into WebView

App.js

import React, { Component } from 'react';
import {
  View,
  WebView
} from 'react-native';

const DataHTML = require('./data.html');

export default class App extends Component<Props> {
  render() {
    return (
     <View>
        <WebView
            source={DataHTML} 
            style={{flex: 1}}
            />                
      </View>
    );
  }
}

data.html

<html>
<head></head>
<body>
    <h1>Hello</h1>
</body>
</html>

1 Answers1

0

Normally the WebView should appear. Try setting flex to 1 for both the View and the WebView or set explicit sizes.

  <View style={{flex: 1}}>
    <WebView
       source={DataHTML}
       style={{flex: 1}}
    />
  </View>

Hope this helps !

sdn404
  • 614
  • 5
  • 7