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 Answer 1

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 !

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.