i want to load local html, css, js file in my react native webview but i am not able to load css which applied to html refer my folder structure
In above is my html and along with css images and js file and I put all in my app folder structure as below
src –> html –> demo –> paster all above files inside this refer below image
Now I am used this html in my actual screen as below
let demoHtmlData = require('../../../html/demo/demo.html')
<WebView
style={{flex: 1}}
source={demoHtmlData}
/>
When i run above code html loaded but css in not applying like colors, styling etc..
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0">
<title>VIVJOA®</title>
<meta name="apple-mobile-web-app-status-bar-style" content="#7D5895">
<meta name="theme-color" content="#7D5895" />
<link href="css/style.css" rel="stylesheet">
</head>
In above code css/style.css not applying my webview so any idea how can i solve this?
2
Answers
you have to place your html and css files in folder for android place inside android_asset inside android folder and for ios place inside resources inside ios folder.
more ref from : WebView Html load from local
Check this official guide: https://github.com/react-native-webview/react-native-webview/blob/master/docs/Guide.md#loading-local-html-files
in this discussion you can find possible ways to solve it:
https://github.com/react-native-webview/react-native-webview/issues/428