Minor tweak to markdown behaviour
This commit is contained in:
+11
-15
@@ -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() {
|
||||||
|
|||||||
Reference in New Issue
Block a user