// @flow
import React from 'react'
import {WebView, StyleSheet} from 'react-native'
import LoadingView from '../components/loading'
import {text as faqs} from '../../docs/faqs.json'
import {tracker} from '../../analytics'

const styles = StyleSheet.create({
  container: {
    flex: 1,
    paddingHorizontal: 30,
    paddingTop: 10,
    paddingBottom: 20,
    backgroundColor: 'transparent',
  },
})

export class FaqView extends React.Component {
  state = {
    html: faqs,
  }

  componentWillMount() {
    this.fetchData()
  }

  url = 'https://stodevx.github.io/AAO-React-Native/faqs.json'

  fetchData = async () => {
    let html = faqs
    try {
      let blob: {text: string} = await fetchJson(this.url)
      html = blob.text
    } catch (err) {
      tracker.trackException(err.message)
      console.warn(err.message)
    }
    this.setState({html: html})
  }

  render() {
    if (!this.state.html) {
      return <LoadingView />
    }
    return <WebView style={styles.container} source={{html: this.state.html}} />
  }
}

@@ -745,24 +745,42 @@
 tch (err) %7B%0A
+      html = faqs%0A
       tracke
@@ -843,24 +843,69 @@
 sage)%0A    %7D%0A
+%0A    if (__DEV__) %7B%0A      html = faqs%0A    %7D%0A%0A
     this.set

load local faqs on development (#619)