Render changelog.md instead of opening a webview using fetch #12

Closed
Ghost wants to merge 6 commits from (deleted):changelog_screen into master
Showing only changes of commit e4a301536d - Show all commits

View file

@ -0,0 +1,47 @@
import React from 'react';
import Markdown from "react-native-markdown-display";
import {withTheme} from "react-native-paper";
/**
* Read a text file and output the content
*
* Example Usage:
* var myTxt = require("./myTxt.txt");
* ...
* <TextFileReader
txt={myTxt}
/>
*/
class TextFileReader extends React.Component {
constructor(props) {
super(props);
this.state = {
text: ""
};
}
componentDidMount() {
this.readTextFile(this.props.text);
}
readTextFile = file => {
let xhr = new XMLHttpRequest();
xhr.open("GET", file, true);
xhr.onreadystatechange = () => {
if(xhr.readyState === 4 && xhr.status === 200){
const allText = xhr.responseText;
this.setState({
text: allText
});
}
};
xhr.send(null);
};
render(){
return (
<Markdown>{this.state.text}</Markdown>
)
}
}
export default withTheme(TextFileReader);