aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/components/Thread.js
diff options
context:
space:
mode:
Diffstat (limited to 'vnext/src/components/Thread.js')
-rw-r--r--vnext/src/components/Thread.js28
1 files changed, 22 insertions, 6 deletions
diff --git a/vnext/src/components/Thread.js b/vnext/src/components/Thread.js
index a17a2022..5393d7d3 100644
--- a/vnext/src/components/Thread.js
+++ b/vnext/src/components/Thread.js
@@ -1,6 +1,9 @@
import 'whatwg-fetch';
import React from 'react';
+import Message from './Message';
+import Spinner from './Spinner';
+
export default class Thread extends React.Component {
constructor(props) {
super(props);
@@ -10,14 +13,27 @@ export default class Thread extends React.Component {
};
}
componentDidMount() {
+ this.loadReplies();
+ }
+ loadReplies() {
+ this.setState({ replies: []})
+ const { mid } = this.props.match.params;
+ const url = `https://api.juick.com/thread?mid=${mid}`;
+ fetch(url)
+ .then(response => {
+ return response.json()
+ })
+ .then(data =>
+ this.setState({ replies: data })
+ ).catch(ex => {
+ console.log(ex);
+ });
}
render() {
- const { user, mid } = this.props.match.params;
- return (
- <div>
- <h1>{user}</h1>
- <p>{mid}</p>
- </div>
+ return this.state.replies && this.state.replies.length > 0 ? (
+ <Message data={this.state.replies[0]}/>
+ ) : (
+ <Spinner />
);
}
}