aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/components/Discover.js
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-02-13 16:20:54 +0300
committerGravatar Vitaly Takmazov2023-01-13 10:37:52 +0300
commit185af998262b3c33ee55aee87a89d9a5948110b1 (patch)
tree9f704f89e1f7c667316c2242497661e90f5408e3 /vnext/src/components/Discover.js
parent5f6126a48678ef56b3e26357ad8491c4892e3d89 (diff)
basic navigation
Diffstat (limited to 'vnext/src/components/Discover.js')
-rw-r--r--vnext/src/components/Discover.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/vnext/src/components/Discover.js b/vnext/src/components/Discover.js
new file mode 100644
index 00000000..2d962bda
--- /dev/null
+++ b/vnext/src/components/Discover.js
@@ -0,0 +1,50 @@
+import "whatwg-fetch"
+import React from "react"
+import PropTypes from "prop-types"
+
+import Message from "./Message"
+
+export default class Discover extends React.Component {
+ constructor(props) {
+ super(props)
+ this.state = {
+ msgs: [],
+ loading: false
+ }
+ this.loadMessages = this.loadMessages.bind(this);
+ }
+ componentDidMount() {
+ this.loadMessages();
+ }
+ componentWillReceiveProps(props) {
+ if (props.params != this.props.params) {
+ this.loadMessages();
+ }
+ }
+ loadMessages() {
+ const search = new URLSearchParams(this.props.params);
+ const url = "https://api.juick.com/messages";
+ fetch(url)
+ .then(response => {
+ return response.json()
+ })
+ .then(data =>
+ this.setState({ msgs: data })
+ ).catch(ex => {
+ console.log(ex)
+ });
+ }
+
+ render() {
+ var nodes = this.state.msgs.map(msg => {
+ return (<Message key={msg.mid} data={msg}/>)
+ });
+ return (
+ <div className="msgs" id="content">{nodes}</div>
+ )
+ }
+};
+
+Discover.propTypes = {
+ msgs: PropTypes.array
+}