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

124
Visualizações
String format /n doesn't work React Native / webview

I use webview to add an editor to my app. The content is saved within the variable Content:

    <script>
        function update() {
            var idoc = document.getElementById('iframe').contentWindow.document;
            idoc.open();
            idoc.write(editor.getValue());
            idoc.close();
        }

let Content= "";
...

I push default text to the editor/Content variable via injectedJavaScript:

<WebView
          ref={(r) => (webref = r)}
          androidHardwareAccelerationDisabled={true}
          scalesPageToFit={false}
          scrollEnabled={false}
          source={{ html }}
          injectedJavaScript={props.defaultContent}
            onMessage={(event) => {
            console.log("EVENT-DATA:", event);
            Content(event.nativeEvent.data);
          }}
        />

injectedJavaScript gets the props defaultEditorContent, which looks like this:

      let defaultEditorContent = `Content += 
      "I am a super long string and I love it!" 
      editor.setValue(Content , 1);
      `;

Everything above works fine. However, I can not format the string "I am a super long string and I love it!".

If I manually add format it like this - no text is shown whatsoever:

 "I am a super long string 
and I love it!" 

If I use \n \n\ there is also no text shown:

 "I am a super long string /n/
and I love it!" 

Any ideas?

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

0

This will help to your answer,

let defaultEditorContent = `
  Content = \`<h1 id ="ali">Hello World! \n 
  </h1>\`;
      editor.setValue(Content , 1);
      `;
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