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

209
Views
React native webview font size change makes text propagate outside

im building a summary view where i import text from and uri inside a webview ad i inject js to change size but when i do that the text go outside the webview.

This is how the uri loads into the webview:

This is how the uri loads into the webview

and this is what i get when i change the font-size:

enter image description here

this is the webview :

  <WebView 
    key={this.state.value}
    ref={webview => this.setState({WebViewRef:webview})}
    javaScriptEnabled={true}
    domStorageEnabled={true}
    scalesPageToFit={false}
    onLoadEnd={
      this.setState({
        visibleBack:false
      })
    }
    automaticallyAdjustContentInsets={false}
    source={{ uri: `http://backend.iferu.com/cleanbook.php?idbook=${this.props.product.id}` }} style={{paddingLeft:15,height:this.state.webViewHeight ,width: Dimensions.get('window').width - 50}}
    key={this.state.key}
    injectedJavaScript={jsBeforeLoad}
    onMessage={this.onMessage}
    scrollEnabled={false}
    style={{ height : this.state.webViewHeight}}    
/>

and this is the js im injecting to change font-size:

sendDataToWebView(){
    let injectedData =
    `
      // document.getElementsByTagName("body")[0].style.fontSize = '${this.state.fontSizeState}px';
      $('#takeAways').css({
        'font-size':${this.state.fontSizeState},
      });
      $('#recomClass').css({
        'font-size':${this.state.fontSizeState}
      });
      $('#summaryTitle').css({
        'font-size':${this.state.fontSizeState}
      });
      $('#summaryText').css({
        'font-size':${this.state.fontSizeState}
      });
      $('#auteurTitle').css({
        'font-size':${this.state.fontSizeState}
      });
      $('#auteurText').css({
        'font-size':${this.state.fontSizeState}
      });
      window.ReactNativeWebView.postMessage(Math.max(document.body.offsetHeight, document.body.scrollHeight));  
    `;
    this.state.WebViewRef.injectJavaScript(injectedData);
  }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It only happens on Android(I'm working on the opposite, actually, to webview font size increase on iOS)

But if you want to lock the font size, you can use textZoom prop.

https://github.com/react-native-webview/react-native-webview/blob/master/docs/Reference.md#textZoom

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!