Question: Hi I know it's a known issue about the auto height of webview in react native,
and I have tried all the possibles solutions I've found on the internet such as :

<https://gist.github.com/epeli/10c77c1710dd137a1335>

<https://github.com/danrigsby/react-native-web-container/blob/master/index.js>

and all the solutions suggested in:
[React native: Is it possible to have the height of a html content in a webview?](https://stackoverflow.com/questions/32952270/react-native-is-it-possible-to-have-the-height-of-a-html-content-in-a-webview)

But unfortunately none of these seems to work for me, 
I understand that the workaround they all suggest is to set the title to the height, but in my case it seems that the title always stays the same which is : 
"text/html ...." and the rest of my html.
I get the html content from an API, it comes without a body, head or html tags, I've also tried adding these tags manually to the html and nothing seems to work.

I would love to hear if anyone else had that problem and how did it get fixed.

Answer: 
Apparently the problem was I had `javaScriptEnabled={false}`.

After enabling it everything worked.
You can get the content height by injecting the JS code as suggested by @ken-ratanachai-s. Although, You will experience certain irregularities in some devices (Extra height after the content). This is becuase the javascript returns the content height in pixels, but we need to use display points in react native. To fix this, Divide the height from javascript with the pixel ratio as follows.

```jsx
import { WebView, PixelRatio } from 'react-native'

const [webviewHeight, setWebviewHeight] = useState(0)

const onProductDetailsWebViewMessage = event => {
    setWebviewHeight(Number(event.nativeEvent.data)/PixelRatio.get())
}

return <WebView
    originWhitelist={['*']}
    style={{ height: productDetailsWebviewHeight }}
    onMessage={onProductDetailsWebViewMessage}
    injectedJavaScript='window.ReactNativeWebView.postMessage(document.body.scrollHeight)'
    source={{ html: "..." }}
/>

```

Pixel ratio ref.: <https://reactnative.dev/docs/pixelratio>

Courtesy: <https://stackoverflow.com/a/65976827/5321660>