0

I'm new to styling with flexbox etc... We have an existing backend with a Q/A system. When calling the API Answers will be returned in HTML. I render the answer in a static webview in my react-native app ~ like so:

<View style={{margin: 16}}> 
 [..]
  <Webview source={{html: solution.description}} style={{flex:1}} />

unfortunately the solution only gets displayed when setting a height - this is impossible since I dont know the solutions length. It doesn't seem to depend on the html - I set it to an example like:

      var html = '<!DOCTYPE html><html><body><h1>This is a heading!</body></html>';

which results in the same problem.

Edit: Screenshot enter image description here

Thanks for your help

dv3
  • 4,369
  • 5
  • 28
  • 50
  • Hi can you at least post screenshots of your app? So that people can understand your problem better. – Mihir Aug 26 '16 at 09:51
  • Sure - I added one. Not sure how it helps though, since the problem is that it doesn't show anything. Under the thumbnail of user "Api User" should be a description of the solution.. – dv3 Aug 26 '16 at 11:22
  • Can't see the screenshot! :| – Mihir Aug 26 '16 at 11:24
  • eh? I can see it, also after deleting the cache... maybe check on your end? – dv3 Aug 26 '16 at 11:26
  • damn corporate firewall. I had to proxy it. I can see now. Please wait.. – Mihir Aug 26 '16 at 11:28

1 Answers1

0

it seems that there is no way to resize your webview height to match the contents. However, I found these links to be helpful for your particular issue.

  1. React Native dynamic webview height
  2. Github
  3. Gist

The second link would surely patch your issue. However, you'll need to refactor a bit. Good luck!

Community
  • 1
  • 1
Mihir
  • 3,812
  • 3
  • 25
  • 29
  • 1
    thx - the repo linked seems to solve the issue. I'll need to refactor it into my code though, since the package on npm is broken. have a good one! – dv3 Aug 26 '16 at 12:12
  • 1
    haha this was actually a coincidence that it set a height correctly. apparently this worked only stable with previous RN versions. e.g. it returns a height of 667 for 1line of text.. damn back to the drawing board – dv3 Aug 26 '16 at 13:11