Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

120
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda