Minor tweak to markdown behaviour

This commit is contained in:
2018-12-14 04:45:19 +11:00
parent 3fe8ccddef
commit d12c18e329
+11 -15
View File
@@ -7,25 +7,21 @@ class MarkdownPage extends React.Component {
super(props); super(props);
this.state = { this.state = {
source: props.source, source: props.source || null,
body: "Loading..." body: props.body
}; };
} }
componentDidMount() { componentDidMount() {
fetch(this.state.source) //if the source is set, grab it from the server and overwrite the body
.then(result => result.text()) if (this.state.source) {
.then((result) => { fetch(this.state.source)
this.setState({ .then(result => result.text())
body: result .then(
}); result => this.setState({ body: result }),
}, error => this.setState({ body: error })
//handle errors here instead of a catch block because internet said so );
(error) => { }
this.setState({
body: error
});
});
} }
render() { render() {