Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

116
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!