react-native-webview.git

InlineWebView.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. *
  7. * @format
  8. * @flow
  9. */
  10. import React, {Component} from 'react';
  11. import {Text, View} from 'react-native';
  12. import WebView from 'react-native-webview';
  13. const HTML = `
  14. <!DOCTYPE html>\n
  15. <html>
  16. <head>
  17. <title>Hello World</title>
  18. <meta http-equiv="content-type" content="text/html; charset=utf-8">
  19. <meta name="viewport" content="width=320, user-scalable=no">
  20. <style type="text/css">
  21. body {
  22. margin: 0;
  23. padding: 0;
  24. font: 62.5% arial, sans-serif;
  25. background: #ccc;
  26. }
  27. h1 {
  28. padding: 45px;
  29. margin: 0;
  30. text-align: center;
  31. color: #33f;
  32. }
  33. </style>
  34. </head>
  35. <body>
  36. <h1>Hello World</h1>
  37. </body>
  38. </html>
  39. `;
  40. type Props = {};
  41. type State = {};
  42. export default class InlineWebView extends Component<Props, State> {
  43. state = {};
  44. render() {
  45. return (
  46. <View style={{ height: 120 }}>
  47. <WebView
  48. source={{html: HTML}}
  49. automaticallyAdjustContentInsets={false}
  50. />
  51. </View>
  52. );
  53. }
  54. }