Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

554
Visualizações
How to show local html in React Native WebView without react-native-static-server or similar?

In React Native project, I have html document in src directory. (Assuming that it named "./src/green.html").

And In MyScreen, I have a WebView for showing this page.

import WebView from 'react-native-webview';
import { Text, View, StyleSheet, Image } from 'react-native';

export default MyScreen (props) {
    const source = require('./green.html');
    const webviewSOurce = Image.resolveAssetSource(source);

    return (
        <View style>
            <WebView
                source={webSource}
                originWhitelist={["*"]}
                style={{
                    width:'100%',
                    minHeight:400
            }}/>
        </View>
    )

}

But it shows the content of html file as a plain text, not html.

    
    <div id="main-div">
    <h1>Hello World! I am alive!</h1>
    </div>

I visited https://github.com/react-native-webview/react-native-webview/blob/master/docs/Guide.md#loading-local-html-files, but I can't get a clear image and react-native-http-server causes some issues on my app.

How can I deal it? Is there any alternative ways to show local html page in WebView without react-native-static-server or react-native-http-server?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I am pretty bad at react, but stumbled across this a couple days ago trying to do the same thing. It's kinda long, so i'll just put the url. https://aboutreact.com/load-local-html-file-url-using-react-native-webview/

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda